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
.