Unix Question! (okay, Linux geeks could help)

Okay, I did the Google groups search, and read a bunch of man pages, and so on, and I’m NOT a Unix geek (yet).

I NEED to concatate two NON-TEXT files in a shell. These are both binary data files (PCL code if that’s important).

I’ve been focused on trying to do this in a shell script, so if there’s a perl way, that would work, too (I know nothing about perl other than the top line of a script says perl in it).

In return, I can show you how to get your networked inkjets working under Mac OS X!

Thanks, Dopers!

Any reason


cat file1 file2 > outfile

won’t work? Am I missing something?

You aren’t missing anything sinemora. Unlike, say, the dos-based “type” command, cat doesn’t filter unprintible characters unless you specifically tell it to, so you can use it to concatinate two binary files.

Just make sure you don’t do “cat file1 file2 >file1”, as that is almost never what you really want to do.

-LV

Ah, that is a very interesting lesson in recursion and globbing. And it also occurs in other circumstances. I first encountered it when I had a directory with files:
file.001.foo
file.002.foo
file.003.foo etc
I foolishly did this command:
cat file* > file.foo
Result? file.foo kept growing in size until it filled my hard disk, and then cat aborted. Ooops.

Just looked that the man page (Google’s cool, type “man cat” and it’s the first choice!) and I have to say DOH! why couldn’t I find that.

I searched and searched Google Groups and all I came up with was references to dang text files, which won’t work.

Thanks! My life is now easier!

Yep, that’s the power of an operating system that assumes you know what you’re doing.

So lesson one here: Read the manpages and, if your system has them (I think most Linux systems do) the info files. This is supported by most commands, as well, and it can give you enough of a hint to pick the right arguments:


*command* --help