On 1/10/06, Zhao Peng <[EMAIL PROTECTED]> wrote:
> While the following line intended to remove quotes does NOT work:
> grep univ abc.txt | cut -f3 -d, | sed s/\"//g >> dev.txt
> It resulted in a line starts with ">" prompt, and not output dev.txt

  The ">" prompt indicates the shell thinks you are still in the
middle of some shell construct, and is prompting you to finish it.  It
usually manifests due to an unclosed quote.  Most likely, something is
eating the backslash that appears before the double-quote in the sed
command.  It should be

     sed s/\"//g

where the second word contains the characters letter s, a forward
slash (/), a backslash (\), a double-quote, two forward slashes (//),
and the letter g.  The backslash tells the shell that the following
character (in this case, a quote) is not to be interpreted as shell
syntax, but instead passed to the specified command "as is".  This is
called an "escape character" or a "shell escape".

  If you're putting this shell command inside some other program or
shell, you may find *that* program also interprets the backslash this
way.  So you need to escape it *twice*:

     sed s/\\"//g

The characters \\ get interpreted by the first program as "literal
backslash here".  The shell then receives a single backslash, which it
applies to the double-quote.

  Shell escapes can get very, very messy.

-- Ben
_______________________________________________
gnhlug-discuss mailing list
gnhlug-discuss@mail.gnhlug.org
http://mail.gnhlug.org/mailman/listinfo/gnhlug-discuss

Reply via email to