Quoting problem

Quoting problem

Post by Barry Margoli » Wed, 03 Nov 1999 04:00:00





Quote:>-=-=-=-=-=-
>-=-=-=-=-=-

>Can someone help me quote the following correclty?

>/bin/sh -c 'echo $C3PDIR | cut -d/ -f3,4 | sed 's/\///''

/bin/sh -c 'echo $C3PDIR | cut -d/ -f3,4 | sed s:/::'

Since the sed parameter doesn't contain any special characters, no quoting
is needed there.  Notice also that I changed the sed delimiter character to
avoid having to escape the slash -- keep this in your repertoire whenever
you're using sed to manipulate pathnames.

--

GTE Internetworking, Powered by BBN, Burlington, MA
*** DON'T SEND TECHNICAL QUESTIONS DIRECTLY TO ME, post them to newsgroups.
Please DON'T copy followups to me -- I'll assume it wasn't posted to the group.

 
 
 

Quoting problem

Post by Syamala Rao Tadigadap » Wed, 03 Nov 1999 04:00:00


 Change the outer single quotes to double quotes.

 And rewrite the command as:

             /bin/sh -c "echo $C3PDIR | cut -d/ -f3,4 | sed 's/\///'"

-Syamal.

-Syamal.
------------

Quote:> Can someone help me quote the following correclty?

> /bin/sh -c 'echo $C3PDIR | cut -d/ -f3,4 | sed 's/\///''

> produces: First RE may not be null
> where $C3PDIR = /apps/c3p/6.1

> Thanks.

> --
> Regards,

> Daniel E. Lincoln

  stadigad.vcf
< 1K Download

 
 
 

Quoting problem

Post by Ken Pizzi » Thu, 04 Nov 1999 04:00:00





>>Can someone help me quote the following correclty?

>>/bin/sh -c 'echo $C3PDIR | cut -d/ -f3,4 | sed 's/\///''

>/bin/sh -c 'echo $C3PDIR | cut -d/ -f3,4 | sed s:/::'

>Since the sed parameter doesn't contain any special characters, no quoting
>is needed there.

This is quite true.  But to answer the asked question, just
for the sake of its educational value (I don't think we've
had this question in the last few weeks, must be time to show
the technique to the new readers of this group):
  /bin/sh -c 'echo $C3PDIR | cut -d/ -f3,4 | sed '\''s,/,,'\'

The idomatic way to "add" a single quote to a single quoted
string in the shell is to:
  + end the string with a ',
  + add a \-escaped ',
  + start a new ' string.
Thus the '\'' sequence in the middle.  Because this idiom would
have left an empty string between the final two 's, I just
omitted those two 's from the final result.

                --Ken Pizzini

 
 
 

1. quoting quotes, problem

Subject:  difficult ( for me ) regexp matching

   I 'd like to replace every occurence of o' in a file
   with \'{o}, ( in order to use latex on the resulting file ).
    I have not found any magic incantation of sed that can treat
   the quote ' literally instead of giving unmatched ' - type errors.
    Any ideas ? I do not want to get in an editor. I 'd like to be able
   to do it as part of a pipe.

Thanks

2. INstalling MUstek scanxpress 1200 UB (USB) HELP needed

3. bash quoting problem

4. ld.so.2

5. quoting problems (tring to "alias" awk cmd)

6. Runtime Application Patcher

7. Impenetrable bash quoting problem (script to convert .APE to .FLAC)

8. ANNOUNCE: New GNU/Linux group in South Goa, India

9. Quoting problems

10. quoting problem with Bourne shell

11. ksh - regular expressions and quoting problem in command

12. Quoting problems in script parameter

13. bash quoting problem