Replacing string in file Unix
sed
has better performance than awk
but both will work for this search and replace. Reference
If you put the commands in a script (e.g., ksh, sh) then here is the syntax:
awk '{gsub(/apple-pie/,"apple_pie");print}' "file1.txt" > "file2.txt"sed -e 's/apple-pie/apple_pie/g' "file1.txt" > "file2.txt"