LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   tar keeps running (https://www.linuxquestions.org/questions/linux-general-1/tar-keeps-running-491551/)

mnauta 10-11-2006 04:24 PM

tar keeps running
 
if I do the following:

Code:

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?

thanks
manuel

matthewg42 10-13-2006 09:07 AM

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).

Code:

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

Code:

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


All times are GMT -5. The time now is 02:59 AM.