#!/usr/bin/
for file in *.txt
do
awk -f f.awk "$file" > "${file}.tmp" && mv "${file}.tmp" "$file"
done
awk script
{
print gensub(/sqrt\(([^)]*)\)/,"&; print*, \"\\1\"","g")
Run the shell script to excecute
sh ./run.sh
This will execute the awk script
example:
input.txt
abc;
sqrt(7);
def;
after we run the script
input.txt will look like following.
abc;
sqrt(7); print, "7";
def;