How Do You Write a Bash Command That Combines a String with Each Line of a File?

Problem scenario
You want each line of a file to have a prefix or suffix attached. How do you print out this combination of a fixed string with each individual line of the file?

Solution

cat foobar.txt | awk '{ print "prefix" $1 "suffix" }'

Leave a comment

Your email address will not be published. Required fields are marked *