How would you merge different input .txt and .tsv files (within a directory) who have the same name but a different extension into an output file?
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It only takes a minute to sign up.Sign up to join this community
ext='(txt|tsv|text|log)' for f (**/*.$~ext(.)) cat < $f >> $f:t:r.merged
The order of merging will be alphabetical within a same directory. That is,
a/file.txt will be included before
Also note that hidden files (those whose name starts with
.) won't be considered (add the
D glob qualifier if you want them).
cat file1.* > file1.merged
cat file2.* > file2.merged