I have a bunch of html files and I want to cat them all (individually) with a header file (several lines at least in length), say header.txt. I'm almost there. I can cat each file with the header file with the following command, but how can I then output the result to save it under the original filename?find . -iname *.html | xargs -L 1 cat header.txt The above prints out what I want, but how can I then reference the xargs argument to add a final > original file name?So in short, I want to insert the text from header.txt into the beginning of every html file. Can I modify the above command to do so? Or alternately are there other ways to achieve this?As an update, here's what I've tried since posting, which hasn't worked:find . -iname *.html | xargs -L 1 cat header.txt {} > {}.newThis does fine except it prints to a file literally named {}.new. That file looks as it should but this isn't helpful.Also tried @Dave's suggestion, but there is a syntax error I can't fix: find . -iname *.html -exec (cat header.txt; cat {}) > {}.new-bash: syntax error near unexpected token `('
Find files with particular filename format, cat each one with a header file, and save result to original file for each such file
cat;xargs
I want to insert the text from header.txt into the beginning of every html file. To prepend the contents of header.txt to all HTML files, use this oneliner:for i in `find . -name '*.html'` ; do cat /path/to/header.txt > $i.tmp && cat $i >> $i.tmp && mv $i.tmp $i ; doneContents of 1.html:first html file contentsContents of header.txt:my headerContents of 1.html after running the script:my headerfirst html file contents(I've tested it, but do backup your files just in case.)