Recursively UNTARing and then TARing back


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Recursively UNTARing and then TARing back
# 1  
Old 12-01-2010
Question Recursively UNTARing and then TARing back

I've just finished writing a shell script that searches for a string recursively in all text files and replace them with another string. Now, all these files come from a location nested deep within some TAR files which are inside another mother TAR.

To make my script work, we had been UNTARing all these TAR files, running the search/replace, then TARing them back. How do I automate this step too by a shell script?
# 2  
Old 12-01-2010
What Operating System do you have?
What Shell do you prefer?
What do you type when doing the job manually?
# 3  
Old 12-01-2010
Java

Quote:
Originally Posted by methyl
What Operating System do you have?
What Shell do you prefer?
What do you type when doing the job manually?
I usually use UNIX or Linux. And bash is what we use mostly. When we do this manually, we type

Code:
tar -xf tarfilename.tar

to extract the TAR files, and then after running the script to search/replace, we go back to every unextracted file's path and then type

Code:
tar -cf tarfilename.tar foldername/


Last edited by exchequer598; 12-01-2010 at 07:31 AM..
# 4  
Old 12-01-2010
Quote:
I've just finished writing a shell script that searches for a string recursively in all text files and replace them with another string. Now, all these files come from a location nested deep within some TAR files which are inside another mother TAR.

To make my script work, we had been UNTARing all these TAR files, running the search/replace, then TARing them back. How do I automate this step too by a shell script?
Presumably you type more than just two "tar" lines.
# 5  
Old 12-01-2010
Quote:
Originally Posted by methyl
Presumably you type more than just two "tar" lines.
Well, a couple of tar lines, for each nested TAR file. Once everything is extracted, we run our script. Once it replaces everything, we put back everything into TARs.
# 6  
Old 12-01-2010
I give up.
# 7  
Old 12-02-2010
Data

Quote:
Originally Posted by methyl
I give up.
SmilieSmilie
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Tar command not taring all files

I am just creating tar.gz file with comand tar -zcvf xyz.tar.gz /home/xyz/* xyz folder contains thousands of files mostly .c, .cpp, etc.. I see that many times all the files are not zipped. Many files(in hundreds) are abruptly left out. What may be the reason for this and how to resolve... (10 Replies)
Discussion started by: rupeshkp728
10 Replies

2. Shell Programming and Scripting

Issue in Untaring the Tar files Script

I have written a below script to untar the tar files from /tmp/tarfiles/ directory. # cat /tmp/tarfiles/script.sh #!/bin/sh cd /tmp/tarfiles/ TFL="tar_files_list.txt" TCF="tar_completed_list.txt" ls -l *.tar | awk '{print $9}' > $TFL for i in `cat $TFL` do if then for j in... (2 Replies)
Discussion started by: thomasraj87
2 Replies

3. Shell Programming and Scripting

Problem untaring gzip

I'm having an issue extracting my tar.gz file. I am trying to compress all directories based on their last modified date (particularly their last modified month), and move them to a different directory by month. When I run my script everything seems to work ok and my compressed file gets moved to... (4 Replies)
Discussion started by: jrymer
4 Replies

4. Shell Programming and Scripting

Taring 2 dir together

Hello everyone, I am trying to tar 2 directories together in KSH. tar -cvf temptarfile.tar scripts tar -cvf temptarfile.tar scripts.2 I need all the files in scripts and scripts.2 to be in one tar file. (1 Reply)
Discussion started by: BrutalBryan
1 Replies

5. Shell Programming and Scripting

Script for Taring the all the folderand move into another server

I Need to run a Unix Aix Shell Script should contains 1)Find all the folders in the directory /fss/fin. 2)Tar the Folders. 3)Move the Tar folders into another directory /fs/fi which in server .s11003232sz.net 4)When user requests untar the Folders and move it back to the orignal... (1 Reply)
Discussion started by: sreekumar
1 Replies

6. Shell Programming and Scripting

TARing multiple files at once

Hi guys, I'm trying to write a quick script to archive off some data once a week. So far I have got; DATE=`date +%Y-%m-%d` TARFILE=${DATE}.tar for file in `find /usr/local/DATA/in -mtime +6`; do tar -czvf ${TARFILE} ${file}; done The problem I have is it is going through the results... (2 Replies)
Discussion started by: JayC89
2 Replies

7. IP Networking

Back-to-Back Connection using HBAs

Hi every body, Is it possible to connect two servers Back-to-Back (Point-to-Point) using HBA adapters & using Fiber. Note it is direct connection & there is no switches between the servers. I'm concern about using HBA adapters, it is possible or not. Thanks in advance. :) (3 Replies)
Discussion started by: aldowsary
3 Replies

8. AIX

back to back printing in UNIX

Hi , Can you suggest me how to back to back printing in UNIX? Is there any way? Kindly advise. Regards Vijaya Amirtha Raj (3 Replies)
Discussion started by: amirthraj_12
3 Replies

9. UNIX for Dummies Questions & Answers

How to move files while Taring..

Hi, When I run the following command the files get TAR but the files in the folder remain intact. tar -cvf TARZIP.10 Nov09/ Is there any way to move them into the folder than just copying them. Thanks and regards, Gideon. (2 Replies)
Discussion started by: preethgideon
2 Replies

10. Shell Programming and Scripting

untaring multiple files

Hi, i'm pretty new to unix and shell scripting and i need to untar a load of files all with different names e.g. YAAN00.V404.T13467.tar, YAAN00.V404.T15623.tar etc with the .T* part following no particular series. I tried to untar them in a script using simply tar -xvf YAAN00.V404.T*.tar ... (3 Replies)
Discussion started by: rinceboy
3 Replies
Login or Register to Ask a Question