On Thu, Nov 18, 2010 at 10:38 AM, tony polkich <[email protected]> wrote: > In --> grep $VAR afile.txt | sed 's/ ? / newdata/' > anotherfile.txt > > what do I insert where the question mark is in sed? $VAR and variations > haven't worked.
Try changing the single quotes to double quotes. So: grep $VAR afile.txt | sed "s/$VAR/ newdata/" > anotherfile.txt Or, more simply: sed "s/$VAR/ newdata/" afile.txt > anotherfile.txt Variables, like $VAR, are not expanded inside single quotes. -- Norman Gaywood, Computer Systems Officer University of New England, Armidale, NSW 2351, Australia [email protected] Phone: +61 (0)2 6773 3337 http://mcs.une.edu.au/~norm Fax: +61 (0)2 6773 3312 Please avoid sending me Word or PowerPoint attachments. See http://www.gnu.org/philosophy/no-word-attachments.html -- SLUG - Sydney Linux User's Group Mailing List - http://slug.org.au/ Subscription info and FAQs: http://slug.org.au/faq/mailinglists.html
