I try to concatenate large files (some GB) in bash. I tried
cat file1 file2 file3 > result
and it didn't work while
cat file1 file2 file3 >> result
worked. In both occasions the file result didn't exist before and my expectation would be, that both commands give the same result.
On the same system I tried the same thing with small files (just some bytes) and both commands produce the same output. I tried to find some explanation (for example here) but couldn't find any...
So, I know how to solve my problem, but I'm still puzzled. Is anyone able to produce a clue?
Input/Output (I/O) redirection in Linux refers to the ability of the Linux operating system that allows us to change the standard input ( stdin ) and standard output ( stdout ) when executing a command on the terminal. By default, the standard input device is your keyboard and the standard output device is your screen.
Before a command is executed, its input and output may be redirected using a special notation interpreted by the shell. Redirection allows commands' file handles to be duplicated, opened, closed, made to refer to different files, and can change the files the command reads from and writes to.
when I need to split file I use a trick that works very well:
tar --one-file-system -czv /home | split -b 4000m - /media/DRIVENAME/BACKUPNAME.tgz
then, to restore :
cat /media/DRIVENAME/BACKUPNAME.tgz.* | tar -x /
so cat do the job whatever the containt is. So if it doesn't work whether there is a bad production of your splited files, or a limitation with your filesystem. What filesystem are you using ?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With