I\'d like to add a header to a tab-delimited file but I am not sure how to do it in one line in linux.
Let us say my file is:
Using sed
no need of temp file
sed -i "s#^#name\tage\tuniversity\tcity#g#"
Demo:
$ cat file1.txt
roger\t18\tcolumbia\tnew york\n
albert\t21\tdartmouth\tnew london\n
etc...
$ sed -i "s#^#name\tage\tuniversity\tcity#g#" file1.txt $ cat file1.txt
name age university cityroger\t18\tcolumbia\tnew york\n
name age university cityalbert\t21\tdartmouth\tnew london\n
name age university cityetc...
$