- Add header to a file using SED command
The below sed command will update the original file and insert the header before the first line of the file.
sed -i '1i COLUMN1,COLUMN2' FF_EMP.txt
2. Add header to a file using AWK command
The below awk command will add header and create a new file. The BEGIN statement in awk makes the statement “COLUMN1,COLUMN2” to get printed before processing the file. The 1 is to indicate to print every line of the file.
awk 'BEGIN{print "COLUMN1,COLUMN2"}1' FF_EMP.txt >> FF_EMP_HDR.txt