Dear all,
Please let me know the meaning of the script.

#zcat compressed_tarball.Z | (cd /export/opt; tar xvfp -)

Actually I am I search of command to untar file in to mew directory. Then I got this,
but I don't understand it.

Hey There,

Basically this line of code is just making use of tar's abililty to read and/or write to/from stdout/stdin

#zcat compressed_tarball.Z | (cd /export/opt; tar xvfp -)

might not always work as expected, though.

Here's a solution or two that are more exact and do just the tar move that you're looking for.

Either, most simply:

1. cd /second_directory ; tar xvpf /first_directory/tarball.tar to extract the tarball.tar in /first_directory into /second_directory

or do a variation on the command above - we'll assume you're in /first_directory
2. tar cpf - tarball.tar|(cd /second_directory;tar xvpf -)

The first part of that second command uses tar to create a file to stdout (-), which it then feeds to the pipe (|), which accepts the first commands stdout and converts it to stdin for command following the pipe.
It's importand to do your cd into /second_directory and tar xvfp - (the - being stdin) within parantheses, so that you're running the two command in a subshell. If you don't do this, only the first command after the pipe will get the stdout from the left side of the pipe and be able to use it as its stdin - so you'd be feeding cd some stdin it wouldn't know what to do with and then trying to use tar to extract a file (stdin) that doesn't exist anymore.

Hopefully this was more helpful than confusing :)

, MIke

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.