![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| unzip files in a different folder | agarwalniru | UNIX for Dummies Questions & Answers | 2 | 03-25-2008 12:36 PM |
| How redirect output(error and normal) to 2 different files | balareddy | Shell Programming and Scripting | 2 | 09-12-2007 10:05 AM |
| Copy files from CD and Unzip | AJD | UNIX for Dummies Questions & Answers | 1 | 04-15-2004 04:43 AM |
| Normal user access to files/folders | gdboling | UNIX for Dummies Questions & Answers | 1 | 12-04-2002 07:46 PM |
| unzip .tgz files | Prafulla | UNIX for Dummies Questions & Answers | 5 | 02-09-2002 07:38 PM |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
unzip particular gzip files among the normal data files
Hello experts,
I run Solaris 9. I have a below script which is used for gunzip the thousand files from a directory. ---- #!/usr/bin/sh cd /home/thousands/gzipfiles/ for i in `ls -1` do gunzip -c $i > /path/to/file/$i done ---- In my SAME directory there thousand of GZIP file and also thousands of data files(already been unzipped) with same name unixtt* bash-2.05$ file unixtt01674 unixtt01674: data bash-2.05$ file unixtt01677 unixtt01677: gzip compressed data - deflate method Is it possible I can just unzip only GZIP unixtt* files leaving the data unixtt* files.?? What should i need to add in the script ?? //purple |
| Forum Sponsor | ||
|
|
|
#2
|
|||
|
|||
|
Quote:
If "file" can tell you what is a gzipped file, then use that to tell you in the script. |
|
#3
|
|||
|
|||
|
purple
my GZIP Files have no extension. its just appear without extension. So, litterally just to see the files it is not possible which one is data and which one is Gzip.
Please provide me the coding lines how to define "file" in script.... |
|
#4
|
|||
|
|||
|
Quote:
Quote:
Code:
file $somefile | grep "gzip compressed data"
if test "$?" = "0"
then
echo $somefile is gzipped
fi
|
|
#5
|
|||
|
|||
|
hi guys,
Below is worked for me. Thanks buddies for the hints-- #!/usr/bin/sh cd /thousand/files/ for i in `ls` do l=`file $i|grep gzip|wc -l` if [ $l -ne 0 ]; then gunzip -c $i > /path/to/file/$i fi done |
|||
| Google The UNIX and Linux Forums |