1833787 Members
2412 Online
110063 Solutions
New Discussion

Re: Reading from tar

 
Waqar Razi
Regular Advisor

Reading from tar

I have an ignite backup tap and I wanna check if particular file is present on the tape, lets say for example /etc/passwd

I am issuing the following command.

tar -tvf /dev/rmt/0mn /etc/passwd

Instead of just listing passwd file, it lists the whole contents of the archive. How can I just check for a single file say /etc/passwd if it is present on archive or not?
7 REPLIES 7
Uday_S_Ankolekar
Honored Contributor

Re: Reading from tar

Did you use grep ?
tar -tvf ..... |grep filename

Good Luck..
Patrick Wallek
Honored Contributor

Re: Reading from tar

Have a look at the tar man page.

The '-t' options lists the names of ALL files in the tar archive. The '-t' option does NOT accept a filename as an argument to list only one file.

So doing:

# tar -tvf /dev/rmt/0mn /etc/passwd

is exactly the same as doing:

# tar -tvf /dev/rmt/0mn

The '/etc/passwd' argument is ignored.
Dennis Handly
Acclaimed Contributor

Re: Reading from tar

The -t option in tar will list ALL files, so you can pipe to grep.

pax(1) allows you to provide a pattern but it will probably read the whole tape.
pax -nv -f /dev/rmt/0mn etc/passwd
-n says it selects the first, so that might work.
Dennis Handly
Acclaimed Contributor

Re: Reading from tar

>... provide a pattern

Make sure you get a listing of what you want to find so you can check your pattern. I.e. if it is a file matching pattern, or something like a regular expression where it isn't automatically anchored with ^ and $.
Rasheed Tamton
Honored Contributor

Re: Reading from tar

mt -t /dev/rmt/0mn fsf 1 ; tar -tvf /dev/rmt/0m /etc/passwd

Make sure to use the no-rewind device to position the tape with mt.

I am not sure may be filename cannot have a leading path, I can't check now.

tar -xvf /dev/rmt/0m etc/passwd

Make a copy of the current /etc/passwd file before you restore.
Deepak Kr
Respected Contributor

Re: Reading from tar

Hi Razi,

Please try using :

# tar -tvf /dev/rmt/0mn|grep "/etc/passwd"


regds,
Deepak
"There is always some scope for improvement"
Sharma Sanjeev
Respected Contributor

Re: Reading from tar

Hi Razi

Check with

tar -tvf /dev/rmt/0mn etc/passwd

etc/passwd not /etc/passwd

Regards
Sanjeev
Everything is Possible as " IMPOSSIBLE" word itself says I M POSSIBLE