extract string

Jeff Kinz jkinz at kinz.org
Tue Jan 10 14:00:01 EST 2006


Ooo, look! - a new business model for Lugs!

Achieve Lug financial independence today!

Now your Lug can achieve its financial funding goals simply by charging
25 cents for each shell scripting homework problem answered and 50 cents
for extended explanations such as rendered below. :-)

All we need now is a PayPal account. :-)

(rendered tongue at least halfway in cheek, all proceeds to
go to GNHLUGS tab at Martha's)



On Tue, Jan 10, 2006 at 01:23:14PM -0500, Ben Scott wrote:
> On 1/10/06, Zhao Peng <greenmt at gmail.com> 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 at mail.gnhlug.org
> http://mail.gnhlug.org/mailman/listinfo/gnhlug-discuss
> 

-- 
Jeff Kinz, Emergent Research, Hudson, MA.
speech recognition software may have been used to create this e-mail

"The greatest dangers to liberty lurk in insidious encroachment by men
of zeal, well-meaning but without understanding." - Brandeis

To think contrary to one's era is heroism. But to speak against it is
madness. -- Eugene Ionesco



More information about the gnhlug-discuss mailing list