quinta-feira, 4 de junho de 2009

7zcat

Sometimes you just want to "grep" someting in a compressed text file, but it is too big to be decompressed and then processed. This is why I love zcat and bzcat: I could decompress and pipe it on the flow to grep/awk/whatever, but unfortunately I do not see a 7zip cat like.

7zip is so awesome because I got better and faster compressions using it, but it's command line options are too many and hard to remember, so I put this alias in my ~/.bashrc:
alias 7zcat='7za e $@ -so 2> /dev/null'



OBS.: the redirection of stderr to /dev/null is because 7z doesn't have a --quiet option.

P.S.: I wonder if there is some way to compress with 7zip exactly like I do with gzip:

echo "foo" | gzip -c > foo.gz
The 7zip manpage gives this example (with gzip compression):
echo "foo" | 7za a dummy -tgzip -si -so > foo.gz
but with 7zip compression, the closest i got was
echo "foo" | 7za a -t7z -si foo.7z
so, how to redirect the output to /dev/stdout when reading from stdin? I mean, it is this possible via some bash-fu, named pipes, etc?


Nenhum comentário: