Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.os.linux.misc > #35756

Re: Quotes in a bash script

From G <g@nowhere.invalid>
Newsgroups comp.os.linux.misc
Subject Re: Quotes in a bash script
Date 2022-10-21 09:47 +0000
Organization <Not Here, Not Me>
Message-ID <jrf84qFjv6qU1@mid.individual.net> (permalink)
References (1 earlier) <tirebs$b183$1@dont-email.me> <jrd88bFak8lU1@mid.individual.net> <tirrve$b81m$1@dont-email.me> <jrddjiFbbamU1@mid.individual.net> <tisag4$dgg7$1@dont-email.me>

Show all headers | View raw


Lew Pitcher <lew.pitcher@digitalfreehold.ca> wrote:
>> 
>> The program is xmgrace, a plotting prog, from the command line 
>>   xmgrace -pexec 'TITLE "Average' -block NSLB3-3d5-11-V.dat -bxy 1:2 
>> plots the proper graph with the title, in the script I have 
>>   xmgrace -pexec \'TITLE\ \"Average\"\' -block NSLB3-3d5-11-V.dat -bxy 1:2
>> And I get the error. 
>>   syntax error: 'TITLE "Average"' 
>> with the right string!
> 
> Yes, of course.
> 
> You've escaped the leading and trailing singlequote so they no longer have
> special meaning to the shell. That means that the xmgrace program will
> receive them verbatum; the argument passed /into/ xmgrace will consist
> of a singlequote, followed by the word TITLE, followed by a space, a
> doublequote, the word Average, another doublequote and a singlequote.
> 
> You can see this if you try using the printf(1) command instead of
> the echo command:
>   16:17 $ printf '[%s]\n' \'TITLE\ \"Average\"\'
>   ['TITLE "Average"']
>   16:17 $ # xmgrace sees the value between the square brackets
> 
> May I suggest
>   xmgrace -pexec 'TITLE "Average"' -block NSLB3-3d5-11-V.dat -bxy 1:2
> 
> The equivalent printf(1) looks like:
>   16:17 $ printf '[%s]\n' 'TITLE "Average"'
>   [TITLE "Average"]
>   16:18 $ # xmgrace sees the value between the square brackets

Yes that worked I was sure I tried that before (as it is the same as the CLI
version) and didn't work, but maybe it was slightly different

Thanks,

G

Back to comp.os.linux.misc | Previous | NextPrevious in thread | Next in thread | Find similar


Thread

Quotes in a bash script G <g@nowhere.invalid> - 2022-10-20 09:47 +0000
  Re: Quotes in a bash script Rich <rich@example.invalid> - 2022-10-20 12:19 +0000
    Re: Quotes in a bash script G <g@nowhere.invalid> - 2022-10-20 15:36 +0000
      Re: Quotes in a bash script Rich <rich@example.invalid> - 2022-10-20 16:06 +0000
      Re: Quotes in a bash script Joe Beanfish <joebeanfish@nospam.duh> - 2022-10-20 16:11 +0000
        Re: Quotes in a bash script G <g@nowhere.invalid> - 2022-10-20 17:08 +0000
          Re: Quotes in a bash script Lew Pitcher <lew.pitcher@digitalfreehold.ca> - 2022-10-20 20:19 +0000
            Re: Quotes in a bash script G <g@nowhere.invalid> - 2022-10-21 09:47 +0000
              Re: Quotes in a bash script "26C.Z969" <26C.Z969@noaada.net> - 2022-11-23 00:00 -0500
  Re: Quotes in a bash script Dominik Ałaszewski <Dominik.Alaszewski@gazeta.pl.invalid> - 2022-10-21 11:12 +0000

csiph-web