[nylug-talk] noob bash sed confusion
Eric Moore
Thu Nov 2 18:42:00 EST 2006
jh <jhlists at hirschman.net> writes:
> I'm trying to use sed in bash, and i'm getting rather confused with
> quotes and escapes. I'm hoping that someone can help...
>
> OK, this works fine from the bash prompt:
>
> sed -e 's/source\ src\ {/source\ src\
> {unix-stream("\/home\/foo2\/dev\/log");/g' file.txt
Try:
sed -e "s,source src {/source src {unix-stream(\"/home/${foo2}/dev/log\");,g"
file.txt
variables are replaced within double quotes, but not single quotes.
I also removed the \'s before spaces, and changed the delimiter for
the s command to a , instead of the usual / so I didn't need to escape
the /'s
> I'd like to do the same thing, but use a variable for the replace
> argument instead of foo2. How can I do this within a bash script?
>
> Thanks
>
> jh
> _____________________________________________________________________________
> Hire expert Linux talent by posting jobs here :: http://jobs.nylug.org
> The nylug-talk mailing list is at nylug-talk at nylug.org
> The list archive is at http://nylug.org/pipermail/nylug-talk
> To subscribe or unsubscribe: http://nylug.org/mailman/listinfo/nylug-talk
--
Eric
More information about the nylug-talk
mailing list