Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

bash output redirection limits?

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?

like image 663
Silentfury Avatar asked Jul 15 '15 11:07

Silentfury


People also ask

What is standard input output redirection in Linux?

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.

How does redirection work in bash?

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.


1 Answers

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 ?

like image 152
dominix Avatar answered Nov 15 '22 09:11

dominix