Sponsored Content
Full Discussion: TAR and ZIP files
Top Forums UNIX for Dummies Questions & Answers TAR and ZIP files Post 302594597 by Vijay81 on Tuesday 31st of January 2012 05:46:00 PM
Old 01-31-2012
thanks for your inputs corona688. My script is getting some input parameters which helps it to find the file names and then lists all the files with specific names and gunzip and tars them to an archive folder. Timestamp is added as part of the tar-red file name to have an option to store multiple files on a day.

I have modified the script to do tar instead of gzip.. please find the modified script attached, I see that a .tar.gz file is created. But in order to verify that it has tar-red properly, I would like to unzip (or do what ever is required) to see the files back in its original state. Can you please help me with how to get the original files seperately?

Also, I am getting the error message below when I run the script.. can you please advice?

SCRIPT:
PHP Code:
cat archival.sh
#### SCript to archieve source file and tar them
#!/bin/sh
date_str=`date "+%Y%m%d%H%M%S"`
ENVID=$1
logfile
=${ENVID}_archival_${date_str}.log
echo Script $0 started at `date` >${logfile}
#### Check if one parameter is received#######
if [ $# -ne 1 ]; then
echo "input parameter for the script is missing" >>${logfile2>&1
exit 1
fi
##### Get the ENVID and DATE_OF_RUN from the parameter file####
parmfilename=${ENVID}_parm.parm
echo $parmfilename >>${logfile}
DATE_OF_RUN=`cat $parmfilename | grep "DATE_OF_RUN" | cut -d"=" -f2`
echo 
$DATE_OF_RUN >>${logfile}
#cd /landing
#### List files based on input parameter####
FILE_LIST=`ls $ENVID_*_$DATE_OF_RUN.$ENVID_*.TXT`
echo 
"files are $FILE_LIST>>${logfile}
for 
FILE in $FILE_LIST
do
#gzip -c $FILE | gzip > $FILE_$(date +"%Y%m%d%H%M%S").gz
tar -zcf ${ENVID}_$(date +"%Y%m%d%H%M%S").tar.gz /opt/informatica/infa_shared/SrcFiles/arch
done
echo "Files are zipped" >>${logfile
Error message:

PHP Code:
tarRemoving leading `/' from member names
tar: Removing leading 
`/' from member names
tar: Removing leading `/' 
from member names
tar
Removing leading `/' from member names 
Thanks!
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

unzip .zip file and list the files included in the .zip archive

Hello, I am trying to return the name of the resulting file from a .zip archive file using unix unzip command. unzip c07212007.cef7081.zip Archive: c07212007.cef7081.zip SecureZIP for z/OS by PKWARE inflating: CEP/CEM7080/PPVBILL/PASS/G0063V00 I used the following command to unzip in... (5 Replies)
Discussion started by: oracledev
5 Replies

2. UNIX Desktop Questions & Answers

Using Tar Zip

Hi, I want to backup my SQL database using tar zip but I'm paranoid that I will archive it. What I mean is I want the files to stay where they are but make a zipped copy of the files as well, I don't want to delete the originals. Is the command? tar -cvzf databasename.tar.gz... (1 Reply)
Discussion started by: chickenhouse
1 Replies

3. Shell Programming and Scripting

To write a shell script which groups files with certain pattern, create a tar and zip

Hi Guru's, I have to write a shell script which groups file names based upon the certain matching string pattern, then creates the Tar file for that particular group of files and then zips the Tar file created for the respective group of files. For example, In the given directory these files... (3 Replies)
Discussion started by: rahu_sg
3 Replies

4. AIX

ZIP multiple files and also specify size of zip file

I have to zip many pdf files and the size of zip file must not exceed 200 MB. When size is more than 200 MB then multiple zip files needs to be created. How we can achieve this in UNIX? I have tried ZIP utility but it takes a lot of time when we add individual pdfs by looping through a... (1 Reply)
Discussion started by: tom007
1 Replies

5. UNIX for Advanced & Expert Users

How to zip/tar millions of files?

Hi guys, I have an issue processing a large amount of files. I have around 5 million files (some of them are actually directories) in a server. I am unable to find out the exact number of files since it's taking "forever" to finish (See this thread for more on the issue). Anyway, now I... (6 Replies)
Discussion started by: verdepollo
6 Replies

6. Shell Programming and Scripting

help with tar & zip only last months(say,Sep) files

Need to 1. archive all the files in a directory from the previous month into a tar/gz file, ignoring all already archived 'tar.gz' files 2. Check created .tar.gz file isnt corrupted and has all the required files in it. and then remove the original files. I am using a function to get the... (1 Reply)
Discussion started by: Prev
1 Replies

7. Shell Programming and Scripting

Zip Multiple files to One .zip file in AIX system

Hi I have a requirement in unix shell where I need to zip multiple files on server to one single .zip file. I dont see zip command in AIX and gzip command not doing completely what I want. One I do .zip file, I should be able to unzip in my local Computer. Here is example what I want... (9 Replies)
Discussion started by: RAMA PULI
9 Replies

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

9. UNIX for Beginners Questions & Answers

How can we Zip multiple files created on the same date into one single zip file.?

Hi all i am very new to shell scripting and need some help from you to learn 1)i have some log files that gets generated on daily basis example: i have abc_2017_01_30_1.log ,2017_01_30_2.log like wise so i want to zip this 4 logs which are created on same date into one zip folder. 2)Post zipping... (2 Replies)
Discussion started by: b.saipriyanka
2 Replies

10. Shell Programming and Scripting

How can we Zip multiple files created on the same date into one single zip file.?

Hi all i am very new to shell scripting and need some help from you to learn 1)i have some log files that gets generated on daily basis example: i have abc_2017_01_30_1.log ,2017_01_30_2.log like wise so i want to zip this 4 logs which are created on same date into one zip folder. 2)Post zipping... (1 Reply)
Discussion started by: b.saipriyanka
1 Replies
All times are GMT -4. The time now is 12:44 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy