wants to extract the tar.gz files
hi,
have more than 50 folders in each folders i have some .gz files how do i extract all the fodler in same time... Please suggest me any script kind of thing to execute .......in linux i user CentOS.. |
Are all of these directories with .gz files in them under one common directory, or are they just randomly spread around?
|
All right, you extract from a gzipped tar archive with
Code:
tar xzf file_name Problem: if you just walk the tree and extract, they'll all extract into the directory you're in rather than the directory where they're found; probably don't want to do that. So you need to use find (to find them) and cd (to get to the directory they're in and some other stuff: Code:
#!/bin/bash |
Thanks For your update, my query is all the .gz files are there in different directories totally i have 50 dir on each directory i have 4 .gz files wants to extract those files...
Can i able to use the above script to extract those files... |
Quote:
You need to change the word path in the following line to the parent directory of the directories where your stuff is stored or to a dot ( . ) (current directory) and cd some_directory_name to execute the program. Code:
for file in $(find path -name '*.tar.gz') As your indicate, you've got 50 directories with who-knows-how-many compressed tar archives in them. You need to tell the shell program where to start looking somehow or other. That can be either the dot or an absolute path, but I'd use the dot and just cd to the directory tree I'm interested in. Hope this helps some. |
Thanks a lot for your update ,i can able to extract all the 50 folders in my desktop....
Thanks you very much..:) :) |
Quote:
Code:
find /search/path -name "*.tar.gz" -exec tar -xzf '{}' \; |
Quote:
|
Maybe this will help a little.
Lets say you have three directories in /usr/local; /usr/local/dirA, /usr/local/dirB and /usr/local/dirC. You want to create three separate tar archives of the content of those directories. If you're working in your home directory, say, /home/yours and do this Code:
/home/yours: tar czf dirA.tar.gz /usr/local/dirA Code:
/home/yours: ls *.tar.gz Code:
usr/local/libA/file.name That's all well and good if you want to restore an archive to it's original location; however, if you want to extract the contents of the archive somewhere else, it's better to Code:
cd /usr/local It's generally easier to do things a step at time rather than all in one go if for no other reason than you have a chance to think about what you're trying to, eh? Hope this helps some. |
All times are GMT -5. The time now is 06:12 AM. |