i've got 2 variables var1 , var2 contain strings. want go through list of files have .txt extension , change occurences of var1 var2. far, looks this:
for in `find . -name "*.txt"` echo $i sed -i -e "s|\$var1|\$var2|g" $i done
i think except sed line working well. think it's syntax issue, haven't been able figure out is. appreciated thanks
you shouldn't need escape $ variable. make sure use lower case -e
, quote filename in case has spaces:
sed -ri -e "s|$var1|$var2|g" "$i"
Comments
Post a Comment