bash add line to beginning of file code example
Example 1: bash add text to the beginning or end of every line
# Basic syntax:
awk '{print "PREFIX"$0}' input_file
# Prepend "PREFIX" to every row in the input_file
awk '{print $0"SUFFIX"}' input_file
# Append "SUFFIX" to every row in the input_file
awk '{print "PREFIX"$0"SUFFIX"}'
# Prepend "PREFIX" and append "SUFFIX" to every row in the input_file
Example 2: add line to beginning of file shell script
$ sed -i '1s/^/added text /' file