Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

find and executing tar 1

Status
Not open for further replies.

Chrissirhc

Programmer
May 20, 2000
926
GB
Why can I do this:

find . -name "filename*" -exec grep -i "find me" {} /dev/null \;

But I can't do this:

find . -name "filename*" -exec tar -tvf {} /dev/null \;

Even when finding filename returns a tar file?

Thanks in advance,

Chris
 
What is the problem ?
You are trying to list all the /dev/null entries in the tar archive.
Try this:
Code:
find . -name "filename*" -exec tar -tvf {} \;

Hope This Help
PH.
 
It does so you get a star!!!, although I didn't fully understand your explanation. Could you expand maybe in some laymans terms.

Thanks a lot,

Chris
 
Another quick question:

Why when I do

find . -name "aFile.tar.Z" -exec zcat {} \; | tar tvf -

I get a list of things:
apple
orange
banana

And then in the same directory I type

find . -name "*.Z" -exec zcat {}\; | tar tvf - | grep "orange"

I get nothing returned.


Thanks again,

Chris
 
Chrissirhc,
A .tar file is an archive file and a .Z file is a compressed file.
The 'zcat' command is used to print out the contents of a compresed text file.
The 'tar tvf' command lists the contents of a TAR archive.
So, keeping the above in mind, what do you wanna do ?
 
Chrissirhc,
As always:
Code:
man find
man tar
FYI:find . -name "filename*" -exec tar -tvf {} /dev/null \;
will do a
tar -tvf ./path/to/filenameSomething /dev/null
for each filename* found in the current directory.
Perhaps the eqivalent command below will be clearer:
Code:
tar -t -f ./path/to/filenameSomething -v /dev/null
    ^   ^_ Name of archive follow     ^  ^_ Entry searched
    |_ List contents of archive       |_ verbose mode

Hope This Help
PH.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top