User Tools

Site Tools


howto:linux_insert_header_in_all_files

Insert the same header (file) in a number of files

The trick here is to use cat and pipe to a tmp file which you then rename to something sensible.

for f in chr*txt; do echo $f; cat header.txt $f > tmp; mv tmp $(basename $f .txt).csv; done

Note that the above assumes the existence of the header in a file (header.txt). Also this will rename each .txt file to .csv.

howto/linux_insert_header_in_all_files.txt · Last modified: 2018/10/09 10:12 by 127.0.0.1