un-tarring multiple files
If I have 10 tarballs in the current directory and I want to un-tar them all, how do I do it?
I've tried: tar-xvf *.tar and it does not work. Thanks in advance for your help. |
You could put them in a loop.
foreach TAR (*.tar) tar -xvf $TAR end John |
I've had the same problem and I tried your loop but it doesnt work.
It says there is en error near unexpected token ( . Any suggestions?I'm gonna keep loooking. |
You're probably using the bash shell. Sorry, that should have occurred to me. Try again in the t-shell.
'tcsh' John |
How about
find <your start directory> -iname "*.tar" -exec tar xvf {} \; Shell-independent ;) Cheers, Tink |
I fixed it so the loop works
#!/bin/bash for TAR in "*.tar"; do echo $TAR done but I still cant untar mulitple files it gives me the following error when I run ./script.sh chmoded 777 : tar : tar2.tar: not found in archive tar : tar2.tar: not found in archive tar : Error exit delayed from previous errors My files are as follows : tar1.tar tar2.tar tar3.tar. I'll try yours with the tcsh shell. |
Yours works tink and so just yours jk when i use the TCSH shell....but I'm still gonna see if I cant get it working with the Bash shell.
|
Well, Tink's answer IS working with the Bash shell. I guess you mean you want to crack the loop approach?
One thing about the 'find' method is that it will also untar anything in subdirectories as well. There's a switch to stop the find descending into subdirectories though. Can't remember what it is, just wanted to post a caveat. John |
XDDD
I figured it out :) #!/bin/bash for TAR in *.tar; do echo $TAR done This untars the files correctly....I almost had it before but I had to delete the quotation marks. Another linux problem down 999 left. :D I'm now gonna make it so it will decompress gzips and bzips also. |
Excellent!
Not so much 999 problems left, as 999 ways to do something! John |
Quote:
;) Cheers, Tink |
True 999 ways to do something. In one day i learned :
How to create a second super user. How to change the login message : Welcome to Linux 2.2.4 (tty1) to what ever I want. How to use the for statement in bash. Here is my script now but now it doesnt do anything ?? #!/bin/sh for TAR in *.tar*; do case "$TAR" in [*.tar.gz] ) tar -xzvf $TAR;; [*.tar.bz] ) tar -xjvf $TAR;; [*.tar] ) tar -xvf $TAR;; esac done my dir structure is : tar1.tar tar2.tar tar3.tar test.tar.gz Any help with that would be appreciated becuase this is the first time ive used the case statement. |
Got it sort of figure out :
#!/bin/sh for TAR in *.tar*; do case "$TAR" in *.tar.gz ) tar -xzvf $TAR;; *.tar.bz ) tar -xjvf $TAR;; *.tar ) tar -xvf $TAR;; esac done Now I get an error about gzip complaing that one of the files are not in gzip format. It does decompress everything now though.Now all I got to do is figure out that error message. Hope this helped the guy who started the thread. |
You're forgetting '*.tgz'! :)
John |
Thanks John thats a pretty important one.
|
All times are GMT -5. The time now is 01:22 PM. |