Mar 3, 2008

Using variables in sed

Question:How to use a variable from the OS in sed?
Example:
$VAR=`Smart keshav`
sed -e 's/keshav/$VAR/g' > filename
Solution:Use double quotes around the sed script rather than single quotes
Example:
sed -e "s/keshav/$VAR/g" > filename

No comments: