I want to combine two or more files in Linux, so I am using the following command:
cat small_file LARGE_File LARGER_FILE > SUM_OF_FILES
However this runs very slow.
Does anyone know a Linux tool that combines the files in the fastest time?
I want to combine two or more files in Linux, so I am using the following command:
cat small_file LARGE_File LARGER_FILE > SUM_OF_FILES
However this runs very slow.
Does anyone know a Linux tool that combines the files in the fastest time?
You could try a variation on the dd command, such as:
dd if=small_file bs=4k of=SUM_OF_FILES
dd if=LARGE_FILE bs=4k of=SUM_OF_FILES oflag=append
dd if=LARGER_FILE bs=4k of=SUM_OF_FILES oflag=append
I've found mmv (Mass Move and rename - Move, copy, append or link Multiple files using wildcard patterns.) from this useful bash reference. So you could do:
cp small_file SUM_OF_FILES
mmv -a LARGE_File SUM_OF_FILES
mmv -a LARGER_FILE SUM_OF_FILES
(note: mmv isn't installed by default, use sudo apt-get install mmv)
Maybe
cat small_file >> LARGE_File
will do what you want? If you need LARGE_FILE to be unchanged
cp LARGE_File SUM_OF_FILES
cat small_file >> SUM_OF_FILES
is better, but this will only be slightly faster than your original code.