in reply to System command stdout

It looks like you want to use the manifest list from a tar package (tar -t) to tell another tar command what to archive. Is this correct? Also, your grep's in the first command line cancel each other out, picking only lines that have "gz" in them anywhere and then removing those same lines using the -v option to negate the "gz" matches (effectively leaving you with no lines of output). Provide a little more clarification on what you are trying to do and we can all possibly lend a hand.

---
echo S 1 [ Y V U | perl -ane 'print reverse map { $_ = chr(ord($_)-1) } @F;'
Warning: Any code posted by tuxz0r is untested, unless otherwise stated, and is used at your own risk.

Replies are listed 'Best First'.
Re^2: System command stdout
by williamj (Initiate) on Nov 27, 2007 at 17:55 UTC
    Wot im trying to do in perl is  tar tf file | grep gz | grep -v sig This should leave just the file.gz filename to pass to stdout Then pass this as a variable to  tar xOf file variable | grep.... I've managed to do this by passing the stdout to a tmp file and reading this in using cat, but I want to do this without using a tmp file.
      On the command line you could do,
      tar -cvf newarchive.tar `tar -tf archive.tar | grep "gz" | grep -v "si +g"`
      However, in your perl program, you could simply backtick to capture the ".gz" filename you want (using Perl's grep), and then pass that to system as the argument to the tar -cvf command. e.g.,
      my @gzfiles = grep { m/gz/ && ! m/sig/ } `tar -tf archive.tar` my @args = ( "tar","-cvf","newarchive.tar", @gzfiles ); system(@args) == 0 or die "Can't archive files: $!\n@gzfiles";

      ---
      echo S 1 [ Y V U | perl -ane 'print reverse map { $_ = chr(ord($_)-1) } @F;'
      Warning: Any code posted by tuxz0r is untested, unless otherwise stated, and is used at your own risk.