Regular Expression delimiters

Rahul Dhesi dhesi at bsu-cs.bsu.edu
Wed Apr 12 03:30:38 AEST 1989


In article <993 at n8emr.UUCP> lwv at n8emr.UUCP (Larry W. Virden) writes:
>
>Using sed as a simple example of a complex situation, how would one code
>a shell program to invoke sed so that the arguments passed would always be
>valid?...
>sed -e /$ans/ filename


First quote those slashes:

   # works from /bin/sh
   pattern="`echo "$ans" | sed -e 's/\//\\\\\\//g'`"
   sed -e "/$pattern/d" filename

Count those backslashes carefully.

What UNIX badly needs is a way of specifying out-of-band characters.
The current quoting scheme causes problems because a level of quoting
is removed at each level of interpretation.
-- 
Rahul Dhesi <dhesi at bsu-cs.bsu.edu>
UUCP:    ...!{iuvax,pur-ee}!bsu-cs!dhesi



More information about the Comp.unix.questions mailing list