Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Click here to return to the 'Merge MP3 files with the Unix command cat' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Merge MP3 files with the Unix command cat
Authored by: bdm on Feb 12, '04 09:41:09PM

Warning, very dangerous practice!

The command
cat * >xx
when executed using tcsh, first creates the file xx, then
expands "*" to include xx, then does the copy. The contents
of xx will be copied into itself forever. I just made a 100 MB file
in a few seconds that way.

In bash, apparently "*" is expanded before xx is created, but if
xx already exists the same disastrous copy-to-self happens.

A better way is to place the output somewhere else temporarily:
cat * >/tmp/xx ; mv /tmp/xx .
Alternatively, replace "*" by a pattern that more explicitly identifies
the input files without matching the output file.


[ Reply to This | # ]
Merge MP3 files with the Unix command cat
Authored by: dogen on Feb 13, '04 05:22:20PM
Thanks for the caveat, Brendon, and sorry the hint ran wild. Another option:
cat * > ../xxx
That puts the merged file in a parent directory to avoid the tcsh endless loop. Incidentally, though perhaps too basic to mention, note that enclosing the filename in quotation marks allows for long names, as in "xxx yyy zzz.mp3"

[ Reply to This | # ]