![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | 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 and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| unzip files in a different folder | agarwalniru | UNIX for Dummies Questions & Answers | 2 | 03-25-2008 03:36 PM |
| How redirect output(error and normal) to 2 different files | balareddy | Shell Programming and Scripting | 2 | 09-12-2007 01:05 PM |
| Copy files from CD and Unzip | AJD | UNIX for Dummies Questions & Answers | 1 | 04-15-2004 07:43 AM |
| Normal user access to files/folders | gdboling | UNIX for Dummies Questions & Answers | 1 | 12-04-2002 10:46 PM |
| unzip .tgz files | Prafulla | UNIX for Dummies Questions & Answers | 5 | 02-09-2002 10:38 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
||||
|
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 |
|
||||
|
Quote:
If "file" can tell you what is a gzipped file, then use that to tell you in the script. |
|
||||
|
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.... |
|
||||
|
Quote:
Quote:
Code:
file $somefile | grep "gzip compressed data"
if test "$?" = "0"
then
echo $somefile is gzipped
fi
|
|
||||
|
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 |
| Sponsored Links | ||
|
|
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|