![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| SUN Solaris The Solaris Operating System, usually known simply as Solaris, is a free Unix-based operating system introduced by Sun Microsystems . |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| thousands separator | ynixon | Shell Programming and Scripting | 11 | 04-13-2008 07:43 AM |
| Multiple (thousands) of Cron Instances | sysera | UNIX for Advanced & Expert Users | 10 | 01-17-2006 05:49 AM |
| How do I send a file as an attachment (gzip file) on a Unix system | lacca | UNIX for Dummies Questions & Answers | 3 | 07-03-2002 10:04 AM |
| gzip in shell script called by cron | hbau419 | Shell Programming and Scripting | 2 | 02-05-2002 03:03 PM |
|
|
Submit Tools | LinkBack | Thread Tools | Display Modes |
|
|||
|
script for Gzip thousands of file
Hi experts,
I have thousands of file (data file and Gziped file) in same directory like below-- bash-2.05$ pwd /home/mmc bash-2.05$ file PP023149200709270546 TT023149200709270546: gzip compressed data - deflate method bash-2.05$ file PP027443200711242320 TT027443200711242320: data i have script which i used before to UNZIP the Gzip files and send it to another directory Among those files Gzip & data files. Code:
#!/usr/bin/sh cd /home/mmc/ for i in `ls PP02*` do l=`file $i|grep gzip|wc -l` if [ $l -ne 0 ]; then gunzip -c $i > /home/mmc/zip/$i fi done Please help me to write the script. |
| Forum Sponsor | ||
|
|
|
|||
|
Hi
The previous time you posted about the similar script I had a hard time understanding your request, so please include all the necessary details in your request. For example what are you going to do with the created files, move them, rename them,...? More details help us to help you. The below script tested on a Linux machine. Code:
for i in `ls | xargs file | awk -F: '! /gzip/{print $1}'`
do
gzip $i
done
#Now the files have the extension gz. If you need to move the files in a different directory afterwards:
for i in `ls | grep gz`
do
mv $i /home/other_dir/
done
Glad to hear you got the script working the first time. Last edited by rubionis; 04-15-2008 at 02:55 PM. Reason: code tags |
|
|||
|
purple
Quote:
-- I will Gzip the data file in the original name of the file. -- I do not want .gz extensions with a Gziped file. -- After Gzip i will send those files in different directory. Please also tell me the explanation of ur below code- Code:
for i in `ls | xargs file | awk -F: '! /gzip/{print $1}'`
|
|||
| Google The UNIX and Linux Forums |