Link to home
Start Free TrialLog in
Avatar of petepalmer
petepalmer

asked on

Quick script

Hi,

I need to write a script that will take all the files ending in .sal in the current directory (say /tmp/) and create individual zip files i.e :

test.sal ->  test.zip

There could be any amount of .sal files...

I'd rather do this with a bash script but can use Perl in a pinch....

Thanks in advance!
Avatar of sunnycoder
sunnycoder
Flag of India image

Hi petepalmer,

find /tmp -type f -name "*.sal" | while read fname
do
       gzip -c $fname > $fname.gz
done

Cheers!
sunnycoder
Avatar of petepalmer
petepalmer

ASKER

Very close.... but.... :)

The final name needs to be (in the case of test.sal) test.zip not test.sal.zip :)

ASKER CERTIFIED SOLUTION
Avatar of sunnycoder
sunnycoder
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
450 to sunny as the answer was spot on, 50 for raven for the assist :)