Unix / bash: reading a list of files and combining them into a file

I am trying to figure out a script file that contains a file containing a list of files (each line is the path to the file, that is, the path / in / file) and merge them into a file.

For instance:

list.text -- path/to/filename filename 

Then call the script like this

merge_script.sh list.txt final_file.txt

Any help is appreciated. I am very disabled with a bash script and I hope that some unix gurus will help me quickly come up with this. Otherwise, it will take me a couple of hours to do it right (well, assuming that I someday understood this). I searched for some examples and combined them. So far no luck.

Thanks Jack

+4
source share
1 answer
 xargs < list.text cat > final_file.txt 

xargs will send file names from list.text to cat batches (so they wonโ€™t overflow the command line). Then, cat will print the contents of each file with the output redirected to final_file.text .

+6
source

Source: https://habr.com/ru/post/1399499/


All Articles