bug-tar
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Bug-tar] feature request: access to archive members by applications lik


From: Hansjoerg Lipp
Subject: [Bug-tar] feature request: access to archive members by applications like grep, md5sum, ...
Date: Mon, 22 Nov 2004 15:58:28 +0100
User-agent: Mutt/1.4.1i

Hi,

I often have the problem that I have to extract tar archives completely
just for executing some command like grep or md5sum. This is annoying if
the archive is large and bad if it is encrypted.

Workarounds like
  IFS=''
  $UNPACK | tar tf - | while read -r line; do
     # convert $line (quote '*', '?', ...)
     $UNPACK | tar Oxf - "$line" | grep ...
  done
don't work very well if the archive contains many files.

As I (and other people I asked) couldn't find any tar option or another
tool which solves this problem, I wrote a patch for GNU tar which allows
something like this:

  $UNPACK | tar E 'grep -q $EXPRESSION && printf %s\\n "$TAR_NAME"'

You can find the patch (which is tested with GNU/Linux and Tru64) at
  
http://www.physcip.uni-stuttgart.de/phy31407/tar/tar-1.14.90-e-03.diff.20041122.01
(applies to tar 1.14.90).

It introduces the operation mode 'E' (for execute) which executes a
command line with "/bin/sh -c" for every member of the archive. If the
member is a regular file, the command can read that file from stdin, if
not, reading from stdin will return EOF.

The external program can find information about the archive member in
environment variables, e.g. TAR_NAME (file name of the member) or
TAR_TYPE (file type: "f" = regular file, "d" = directory, ...).

If you specify the operation modifier 'e', non zero exit codes of the
commands are treated as errors.

Is this also useful for other people? Are you interested in this patch?
Do you have any suggestions?

Regards,
Hansjoerg Lipp




reply via email to

[Prev in Thread] Current Thread [Next in Thread]