Friday, February 2, 2007

SED and variable access


Q: Why don't my variables like $var get expanded in my sed script?

Ans : Instead of the 'single quotes' we need to use "double quotes" , unix shells never expand $var in single quotes
so

$ S="asd"; echo "asd_2310" sed "s/2310/$S/g"
asd_asd

No comments:

© Jadu Saikia www.UNIXCL.com