Answers for "awk replace string in file with variable"

0

awk replace string in file with variable

awk -i inplace  -v cuv1="$word" -v cuv2="$replace" '{gsub(cuv1,cuv2); print;}' "$file"
Simpler solutions using sed and perl:

sed -i "s/$word/$replace/g" "$file"
perl -i -pe "s/$word/$replace/g" "$file"
Posted by: Guest on March-29-2021

Code answers related to "awk replace string in file with variable"

Browse Popular Code Answers by Language