I'm using a sed command in a bash script from variable expansion, so I
can use it like this:

$CMD file

The command is the following:
sed -e 's/\(\([^|]*|\)\{22\}[^|]*\)|.*/\1/'

It makes sure that any trailing characters [beginning with |] beyond the
initial 23 pipe-delimited columns will be stripped off, and it does work
outside of this script that I'm writing.

However, I can't get the command to work.  Per the bash man page, ', ",
and \ need to be escaped (for Quote replacement), so I've tried this:

CMD="sed -e \'s/\\(\\([^|]*|\\)\\{22\\}[^|]*\\)|.*/\\1/\'"

also this:

CMD="sed -e 's/\(\([^|]*|\)\{22\}[^|]*\)|.*/\1/'"

and several other variations.

Any suggestions for getting this to work using variable substitution?

Casey


--------------------
BYU Unix Users Group 
http://uug.byu.edu/ 

The opinions expressed in this message are the responsibility of their
author.  They are not endorsed by BYU, the BYU CS Department or BYU-UUG. 
___________________________________________________________________
List Info: http://uug.byu.edu/cgi-bin/mailman/listinfo/uug-list

Reply via email to