Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...


Hi,
i want to zip the files that generates automatically
every few minutes (files generated are in .arc
extension)....any body write a script for this...
thanks in advance

Answers were Sorted based on User's Feedback



Hi, i want to zip the files that generates automatically every few minutes (files generated are..

Answer / srinivas

Assuming the *.arc files are getting generated under every
5 minutes..

Create script.sh and cut paste the following contents
--------------------------
while true
do
for i in `ls *.arc` ;
do
ls *.arc 2> /dev/null
if [ $? -eq 0 ]
then
gzip $i
else
echo "No files to be zipped at this moment...Exiting"
exit 1
done
sleep 300
done
--------------------------

Hope this helps

-- Srini

Is This Answer Correct ?    2 Yes 0 No

Hi, i want to zip the files that generates automatically every few minutes (files generated are..

Answer / vipul dalwala

while true
do
find . -name *.arc -exec gzip {} \;
sleep 300
done

Is This Answer Correct ?    2 Yes 0 No

Hi, i want to zip the files that generates automatically every few minutes (files generated are..

Answer / vipul dalwala

while true
do
THIRDFILE=`ls -t | sed -n '3p'`
find . -name '*.arc' ! -newer ${THIRDFILE} -exec gzip {}
\;
sleep 300
done

Is This Answer Correct ?    1 Yes 0 No

Hi, i want to zip the files that generates automatically every few minutes (files generated are..

Answer / sandeep

Mr srinivas , i want last 2 files not to be zipped, rest
files should be zipped...

Is This Answer Correct ?    0 Yes 1 No

Hi, i want to zip the files that generates automatically every few minutes (files generated are..

Answer / narendrasairam

One way is to keep the code snippet in while loop with a
sleep time of 300 seconds (expecting 5 minutes time gap)


while true
do
FILE_EXIST_CHECK=`ls -l | grep ^- | wc -l`
if [ $FILE_EXIST_CHECK -ne 0 ];
then
if [ -f *.arc ];
then
ls *.arc > arc_files.lst
while read arc_filename
do
/usr/local/bin/gzip $arc_filename > /dev/null 2>&1
done < arc_files.lst
fi
else
echo " There are no .arc files existing...."
fi
sleep 300;
done

The other way is to schedule the job using crontab with a
time slice of minutes with out keeping in while true loop.

Is This Answer Correct ?    0 Yes 1 No

Post New Answer

More Shell Script Interview Questions

What does it mean to debug a script?

0 Answers  


What are the Different types of shells?

5 Answers  


What is a program shell?

0 Answers  


what does "kill -9" and "kill -1" do

2 Answers   Amazon,


What is the best shell scripting language?

0 Answers  


Explain about the slow execution speed of shells?

0 Answers  


What is mac default shell?

0 Answers  


Please give me example of " at command , contrab command " how to use

0 Answers  


how do you write sql queries using shell script for eg:- we have databae table like EMPNO,ENAME,SAL,DEPTNO columns in EMP table how you display EMPNO,SAL FIELDS from emp in SHELL SCRIPT please explain with an example

4 Answers  


Is scripting and coding the same thing?

0 Answers  


What is a beat in a script?

0 Answers  


Determine the output of the following command: [ -z “” ] && echo 0 || echo 1

0 Answers  


Categories