How to process the files using .tar.gz files in script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How to process the files using .tar.gz files in script
# 1  
Old 05-03-2007
How to process the files using .tar.gz files in script

Hi,

I have some file in /users/xyz directoty with .tar.gz extension. i need to find these files and if found in need to run other commands. I now the command for finding files,but how to put if condition ?please help me


Thanks
# 2  
Old 05-03-2007
try this

#!/usr/bin/ksh

if [ -f /users/xyz/*.tar.gz ];
then
<do something
fi
# 3  
Old 05-04-2007
Thanks for your reply. Now i am trying to run the following script,
Script name is TestScript.sh#!/bin/sh

if [ -f /users/home/conmjr/*.txt];

then

cd /users/back_scan

fi

But , i am getting the foolowing error

./TestScript.sh: test: ] missing


is there worng in my script
# 4  
Old 05-04-2007
space

Put a space between the last character and the close bracket ]
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to create zip/gz/tar files for if the files are older than particular days in UNIX or Linux?

I need a script file for backup (zip or tar or gz) of old log files in our unix server (causing the space problem). Could you please help me to create the zip or gz files for each log files in current directory and sub-directories also? I found one command which is to create gz file for the... (4 Replies)
Discussion started by: Mallikgm
4 Replies

2. Solaris

Command to remove existing files in the tar files in Solaris 10

Hi, I am using solaris 10 OS.Please help me out with the commands needed in below two scenarios. 1)How to delete the existing files in the tar file. suppose i have a main tarfile named application.tar and it contains a file called ingres.tar. what is the command to remove ingres.tar... (2 Replies)
Discussion started by: muraliinfy04
2 Replies

3. Shell Programming and Scripting

How to tar files inside a script?

Hi , I have a file which contains few file names. I need to tar those files but am unable to do inside the script. Any help will be useful. cat /tmp/test aa.txt bb.txt cc.txt I have tried the below code but its not working. for i in `cat /tmp/test';do tar -cvf TEST.tar $i;done (9 Replies)
Discussion started by: rogerben
9 Replies

4. 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

5. Shell Programming and Scripting

Backup script to split and tar files

Hi Guys, I'm very new to bash scripting. Please help me on this. I'm in need of a backup script which does the ff. 1. If a file is larger than 5GB. split it and tar the file. 2. Weekly backup file to amazon s3 using s3rsync 3. If a file is unchanged it doesn't need to copy to amazon s3 ... (4 Replies)
Discussion started by: ganitolngyundre
4 Replies

6. Shell Programming and Scripting

tar command to explore multiple layers of tar and tar.gz files

Hi all, I have a tar file and inside that tar file is a folder with additional tar.gz files. What I want to do is look inside the first tar file and then find the second tar file I'm looking for, look inside that tar.gz file to find a certain directory. I'm encountering issues by trying to... (1 Reply)
Discussion started by: bashnewbee
1 Replies

7. Shell Programming and Scripting

Need script to tar files older than 30 days

Hi all. Here's my situation: I have performance reports that run every 30 minutes saved in the format: stats_report_11251000.txt stats_report_11251030.txt stats_report_11251100.txt stats_report_11251130.txt (Obviously run at Nov 25 10 AM, 10:30 AM, 11 AM and so on...) I would... (2 Replies)
Discussion started by: jamie_collins
2 Replies

8. UNIX for Advanced & Expert Users

How to create a Tar of multiple Files in Unix and FTP the tar to Windows.

Hi, On my Unix Server in my directory, I have 70 files distributed in the following directories (which have several other files too). These files include C Source Files, Shell Script Source Files, Binary Files, Object Files. a) /usr/users/oracle/bin b) /usr/users/oracle... (1 Reply)
Discussion started by: marconi
1 Replies

9. Shell Programming and Scripting

Script to tar up old log files

Hell All! I need help writing a script for my job. I never really wrote alot of scripts but I guess it a first time for everything. I need to write a simple script that goes out to our log file directory on our servers and tar and compress them. I need to know how to add an date time stamp to tell... (5 Replies)
Discussion started by: aojmoj
5 Replies

10. Shell Programming and Scripting

bash - batch script for extracting one file from multiple tar files

so i have hundreds of files named history.20071112.tar (history.YYYYMMDD.tar) and im looking to extract one file out of each archive called status_YYYYMMDDHH:MM.lis here is what i have so far: for FILE in `cat dirlist` do tar xvf $FILE ./status_* done dirlist is a text... (4 Replies)
Discussion started by: kuliksco
4 Replies
Login or Register to Ask a Question