Problem scenario
You want to substitute the nth word of a given line. How do you use awk to accomplish this?
Solution
Let's assume the lines that you want to modify are in goodfile.txt. To replace the fourth item in the string with "new string", run this command:
cat goodfile.txt | awk '{ print $1 " " $2 " " $3 " new string " $5 " " $6 }'