Personally, I would go with nano -w file.txt ;-) (i.e. just use a text editor, it doesn't have to be nano)
But if you want to do this in a non-interactive environment for any reason, you can use cat for all kinds of concatenations:
echo $'name\tage\tuniversity\tcity' | cat - file.txt > file2.txt
will add a header and put the output in file2.txt . If you want to overwrite the original file, you can do this with
echo $'name\tage\tuniversity\tcity' | cat - file.txt > file2.txt; mv file{2,}.txt
Or you can use sed as follows:
sed -i $'1 i\\\nname\tage\tuniversity\tcity' file.txt
Note that I'm using $'...' quoting to allow me to use \t to represent a tab and \n to represent a new line (among other substitutions, see the bash man page for more). In this type of quoted string, \\ is a literal backslash. So the program passed to sed is actually
1 i\ name age university city
David z
source share