Re: Useful use of cat



Henry Townsend wrote:
Kevin Collins wrote:

In article <z96dnY3d37YLDyHeRVn-jQ@xxxxxxxxxxx>, Henry Townsend wrote:

Darren Dunham wrote:

The last one on that page (not posted in your list) is the most common
for me.  Using cat to hand a pipe rather than a file to a non-largefile
aware filter:

% gzip <largefile>    vs
% cat <largefile> | gzip

You presumably meant to contrast with:

   % gzip < <largefile>

as we all know there's a significant difference between "cmd file" and "cmd < file".


Actually, I don't think he did, although that will probably also work around
gzip's largefile limitation.


Possibly. There are three programs potentially involved here (cat, gzip, and the shell). Thus "gzip largefile" will fail if gzip doesn't know how to open large files[*], "gzip <largefile" will fail _only_ if the shell doesn't know how to open large files, and "cat largefile | gzip" will only help if both gzip and your shell are broken and cat is not. I'd be interested to see a system where this is the case. I can believe (versions of) gzip being broken for large files but have trouble imagining a system where cat had been fixed up and the shells hadn't. Not to mention that if your shell can't handle large files, where are you going to write the gzip/zcat output to?

[*] Basically a matter of passing O_LARGEFILE to open().

So true! The answer to your question can only be:

cat largefile | gzip | dd of=largefile.gz

provided that dd is largefile capable.


-- Michael Tosch @ hp : com .



Relevant Pages

  • Re: Useful use of cat
    ... Using cat to hand a pipe rather than a file to a non-largefile ... % gzip <largefile> vs ... and the shell). ...
    (comp.unix.shell)
  • Re: strip leading X bytes from binary file.
    ... but he put in a UUOC. ... compressed with gzip. ... The 'cat' is needed if you have to send the output ... to a file because the decompressor can only work on files, ...
    (comp.unix.shell)
  • Re: cat gzip files
    ... Giorgos Keramidas wrote: ... If I have a few thousand .gz files and I cat them together into one ... gzip is really mean to allow this: ... Ivan Novick ...
    (comp.unix.programmer)