> How can I pass a shell variable into a sed script pattern space? > > I've seen two (2) means documented elsewhere; but, I cannot get them to > work in Dachstein-CD: > > sed -n '/'"$var"'/p' file > > sed -n '/$(var)/p' file > > Yes, I've found that I can do it this way; but, I'd prefer a single > step: > > regx="/$var/p" > sed -n $regx file > > What do you think?
You're being tripped up by shell quoting. Read the ash man page available on my site: http://lrp.steinkuehler.net/Documentation/ash.html You may have to read it several times (I still have to go back to it frequently), but it should have everything you need to get going. Basically, the problem is most sed commands have wierd shell meta-characters in them, so you need to quote them to prevent the shell from mucking the command up before it gets passed to sed. Quoting the sed command, however, can interfere with variable substitution, as you have discovered. See the ash man page for the skinny on how everything works, and the POSIXness scripts for some crafty 'real-world' examples... Charles Steinkuehler http://lrp.steinkuehler.net http://c0wz.steinkuehler.net (lrp.c0wz.com mirror) _______________________________________________ Leaf-user mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/leaf-user
