i'm trying to overwrite the contents of a file with the output an awk substitution. below is the substitution that i am using.
awk '{ "sub(/string/, /newstring/)" } file'
i have tried variations of print and echo using | and > and whilst i know the command itself works i cannot understand how to make use of the output.
awk 'BEGIN { print "sub(/string/, /newstring/)"; > "file" }' file
this only prints the contents of the ""
awk 'BEGIN { print ${sub(/string/, /newstring/)}; > "file" }' file
this provides syntax errors
awk 'BEGIN { print "${sub(/string/, /newstring/)}" > "file" }' file
this only prints the "" again