Share your knowledge at the LQ Wiki.
Go Back > Forums > Linux Forums > Linux - General
User Name
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.


  Search this Thread
Old 10-11-2006, 04:24 PM   #1
Registered: Apr 2003
Location: Austin, TX
Distribution: Centos 6 / 7
Posts: 150

Rep: Reputation: 15
tar keeps running

if I do the following:

tar -tvf /dev/st0 home/mydirectory/folder/myfile.txt
the file is found, but tar keeps running. Does it continue to search the entire tape (it's a 40Gig tar file)? If so, is there a way to make it stop right after it finds the first match?

Old 10-13-2006, 09:07 AM   #2
Senior Member
Registered: Oct 2003
Location: UK
Distribution: Kubuntu 12.10 (using awesome wm though)
Posts: 3,530

Rep: Reputation: 63
Thumbs up

tar files can contain multiple occurrences of a file, so by default it will scan right to the end of the file to report subsequent instances of the file if they exist. You can tell GNU tar (not sure about other implementations) to report just one occurrance using the --occurrance option. This is documented in the info pages (but not the debian man page, which is incomplete).

tar -tvf /dev/st0 --occurrence home/mydirectory/folder/myfile.txt
This should list the first --occurrence of home/mydirectory/folder/myfile.txt and then terminate without scanning the rest of the archive.

Notice that the --occurrence option can take a numerical argument. For example, to list the third occurrance of the file, use

tar -tvf /dev/st0 --occurrence=3 home/mydirectory/folder/myfile.txt
If you don't specify the number, it defaults to 1.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
how can i decompress this tar.tar file? hmmm sounds new.. tar.tar.. help ;) kublador Linux - Software 14 10-25-2016 02:48 AM
tar tar cvf - . | (cd /root/; tar xvf -) ewt3y Linux - General 10 02-19-2014 10:55 AM
Can anyone tell me what I need to do when running into a tar: Unexpected EOF error? schmootsypoo Linux - Software 2 09-03-2004 07:50 AM
Diferance between rpm, tar, tar.gz, scr.tar, etc mobassir Linux - General 12 08-21-2003 06:30 AM
Running installed .tar.gz apps -=DpG26=- Linux - Software 5 08-10-2003 05:45 PM > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 05:49 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration