To concatenate files you use
cat file1 file2 file3 ...
To get a list of quoted filenames sorted by time, newest first, you use
ls -t
Putting it all together,
cat $(ls -t) > outputfile
You might want to give some arguments to ls
(eg, *.html
).
But if you have filenames with spaces in them, this will not work. My file.html
will be assumed to be two filenames: My
and file.html
. You can make ls
quote the filenames, and then use xargs
, who understands the quoting, to pass the arguments to cat
.
ls -tQ | xargs cat
As for your second question, filtering out parts of files isn't difficult, but it depends on what exactly you want to strip out. What are the “redundant headers”?