LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   tar command will only do one file at a time (https://www.linuxquestions.org/questions/linux-newbie-8/tar-command-will-only-do-one-file-at-a-time-49909/)

Travis86 03-14-2003 10:17 PM

tar command will only do one file at a time
 
I'm trying to untar and ungzip three tar.gz . First I tried the command: tar -fixz *.tar.gz, but I found I needed to rearrange the letters. I ended up with tar -xzf ./*tar.gz . It says the files I want to open are "not found in archive." What does that mean?

(BTW, the tar command works when I try to do just one file.)

Dark_Helmet 03-14-2003 11:51 PM

When I use tar, I never use the dash (it's not necessary) and I always use the 'v' option (verbose) mode. So try something like this:

tar xvzf *.tar.gz

If that doesn't work, try doing it specifically for each file. I'd bet one (or more) of them is bad. Then if you're really nosy, you can whip out gzip to test the integrity of the gz file(s) that fail, and maybe even use tar to check the tar archive as well.

joesbox 03-15-2003 12:37 AM

i have run into something like this.
i had to gunzip the files first then untar them. don't know how to get past the multi file prob but maybe if you try this
(after gunzip)
tar -xvf filename.tar filename.tar

now i don't know if this will work or not i have never tried it.

Freestone 03-15-2003 01:00 AM

Try the following:


tar -cvf - files | (cd target directory ; tar xpf -)

This will copy the file to a the new directory in an uncompressed state.

Good luck,

Freestone

fsbooks 03-15-2003 07:27 AM

If you type tar --help, at the begining you will see the following:
Quote:

GNU `tar' saves many files together into a single tape or disk archive, and
can restore individual files from the archive.

Usage: tar [OPTION]... [FILE]...

Examples:
tar -cf archive.tar foo bar # Create archive.tar from files foo and bar.
tar -tvf archive.tar # List all files in archive.tar verbosely.
tar -xf archive.tar # Extract all files from archive.tar.
Note that there is one (and only one) option to f which specifies the file (device or whatever) to be processed. Note the the [FILE] has a trailing ... That means you can restore(write) many files.

Try the following:
"echo tar -xzf ./*tar.gz"

You will get something like:
tar -xzf ./tarfile1.tar.gz ./tarfile2.tar.gz ./tarfile3.tar.gz

This means you are telling tar to extract the files ./tarfile2.tar.gz ./tarfile3.tar.gz from the file ./tarfile1.tar.gz. This is why it says .the files are "not found in archive."

If you want to do all the tarfiles at once, try the following:

"for file in *.gz; do tar -xzf $file; done"

Of course, you may want to try the following first: so you can see what would happen

"for file in *.gz; do echo tar -xzf $file; done"


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