Help with untarring multiple files from tarred directories and subdirectories


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Help with untarring multiple files from tarred directories and subdirectories
# 1  
Old 11-21-2011
Help with untarring multiple files from tarred directories and subdirectories

Hi,

I want to untar all log files from following tarred directory hierarchy

Log_files.tar.gz/subject*.tar.gz/project*/*.log

It means there are subject1.tar.gz to subject9.tar.gz and in those tarred subect directories there are project1 - project5 directories and in those directories there are multiple log files.

I want to untar and "remove" all log files from those project directories to new directory untar_log_files/subject*/project*.

I have tried tar -zxvf Log_files.tar.gz Log_files/subject*/project*/*.log
but not working!

any help would be appreciated.

Thanks
RV
# 2  
Old 11-21-2011
tar does not take * wildcards when you are trying to extract files by name.

And, if you have compressed files inside a tar file, tar cannot decompress them and extract from them until they are standlone tar archive files.

All this assumes I understood what is going on here. Correct me where I don't get it.
# 3  
Old 11-21-2011
Hi jim,

Thanks for the response.
What I believe is tar can use wildcard * but you are right it cannot untar file from inside the other compressed tar files.

I came up with solution where the directories Log_files/subject1/project* all are already created and it works with

tar -zxvf Log_flies/subject1.tar.gz Log_files/subject1/project*/*.log

However is there any way wherein the directories are created when I untar it and I dont need to make the directories manually.

Thanks,
rv
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Zip all the files including directories - subdirectories

Hi, Is is possible to zip a folder and all its contents within the folder ( including sub-directories and files) into a zip file? and can regain the same structure if unzipped? Thanks (6 Replies)
Discussion started by: rudoraj
6 Replies

2. Shell Programming and Scripting

Script to find & replace a multiple lines string across multiple php files and subdirectories

Hey guys. I know pratically 0 about Linux, so could anyone please give me instructions on how to accomplish this ? The distro is RedHat 4.1.2 and i need to find and replace a multiple lines string in several php files across subdirectories. So lets say im at root/dir1/dir2/ , when i execute... (12 Replies)
Discussion started by: spfc_dmt
12 Replies

3. UNIX for Dummies Questions & Answers

show all text files in directories and subdirectories

Hi! I am trying to find all text files in my home directory that contain the string "C-d" so I tyied this : cd ~ find . -type f -exec grep -l "C-d" {} + but it took very long so I tryed this : ls -aR | xargs file |grep text but it didn't descend in the directories and it said :... (3 Replies)
Discussion started by: kelamahim
3 Replies

4. Shell Programming and Scripting

perform 3 awk commands to multiple files in multiple directories

Hi, I have a directory /home/datasets/ which contains a bunch (720) of subdirectories called hour_1/ hour_2/ etc..etc.. in each of these there is a single text file called (hour_1.txt in hour_1/ , hour_2.txt for hour_2/ etc..etc..) and i would like to do some text processing in them. Each of... (20 Replies)
Discussion started by: amarn
20 Replies

5. Shell Programming and Scripting

Error in concatenating multiple files from subdirectories

I want to concatenate multiple files recursively from sub-directories intoone file in Linux. I saved the following script as script.sh in $HOME/testing1 where I have several subdirectories and .txt files into them. I ran script.sh from the command prompt of $HOME/testing1 as ./script.sh. But it... (3 Replies)
Discussion started by: raj284
3 Replies

6. Shell Programming and Scripting

Problem in concatenating multiple files from subdirectories

I want to concatenate multiple files recursively from sub-directories intoone file in Linux. I saved the following script as script.sh in $HOME/testing1 where I have several subdirectories and .txt files into them. I ran script.sh from the command prompt of $HOME/testing1 as ./script.sh. But it... (3 Replies)
Discussion started by: raj284
3 Replies

7. Shell Programming and Scripting

Compress files as per timestamp in multiple subdirectories

I'd really appreciate if anyone could assist me with this code A directory with multiple subdirectories has multiple files which are timestamp'ed. We need to - compress files as per timestamp - save compressed file/s in the respective folder - delete the source files ============... (2 Replies)
Discussion started by: sreewin7
2 Replies

8. UNIX for Dummies Questions & Answers

Tarred files not being put on tape

Hi I normally backup to tape using the following command in Solaris 9 on SUN Enterprise 3500 server: tar cvf /dev/rmt/0n data but after a power cut, the server went down without being shutdown since the UPS failed. Now when I issue the tar command I get the root (/) being full looks like it... (6 Replies)
Discussion started by: rahmantanko
6 Replies

9. Shell Programming and Scripting

How to Remove Ctrl M characters in files from directories and its subdirectories

Hi, How to recursively remove Ctrl M characters in files from a directory and its sub directory ? I know unix2dos command is there but to remove in bunch of files ... ? Thanks (7 Replies)
Discussion started by: skdp
7 Replies

10. UNIX for Dummies Questions & Answers

sftp multiple files and subdirectories

Hi, I'm new to using the sftp command prompt within the unix shell (usually I just use an FTP windows program). I've successfully connected to a remote server from within ssh. I've also been able to copy multiple files using the mget command e.g. mget *.html How do I copy all files,... (3 Replies)
Discussion started by: robbieg
3 Replies
Login or Register to Ask a Question