Hello,
I'm trying to split a file by lines. I know that I can use the split command to do this, but the one problem I'm having is, each file created, the first line needs to be a header. I can use the split command the create another file with the header, then append the new split file to it. I do not like this approach. So I'm hoping someone may enlighten me.
just a suggestion but this one is an easy one...
awk '{if (FNR==1}{print FILENAME ; print $0}else print $0}' file1 file2 file3 ........> inputfile
not very fancy but will place FILENAME of every file as the header of that file and append the next name of file as header and the file proceeding the header..
you can also use the -v option to set a variable for the header instead of using the FILENAME option.
moxxx68
This will concatenate the files, not split them as per the original posters request.
Also, your redirection to "inputfile" is misleading - the ">" redirection operator redirects STDOUT, therefore a more apt name for the resulting file would be "outputfile"