Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I have a bash script where I'm zipping some files. This process sometimes takes time depending on the file sizes. I want to get the pid of this command and display a flashing message "Zipping..." until the process completes, something like the following:

zip -r test.zip *.php > /dev/null &
pid=$!
while (kill -0 $pid)
do clear
sleep 1
echo "Zipping......."
sleep  1
done

Is $pid the accurate PID of the zip command I'm running?

share|improve this question
    
First off, you don't need all those semicolons. You also need a space after sleep, so it'd be sleep 1. –  Wuffers May 7 '11 at 21:26
add comment

1 Answer 1

up vote 4 down vote accepted

You can make TEXT blink by:

printf "\x1b[5mTEXT\x1b[25m"

With some clean-up:

zip -r test.zip *.php > /dev/null &
pid=$!

while (kill -0 $pid) ; do
    clear
    printf "\x1b[5mZipping...\x1b[25m"
    sleep 1
done

With some more clean-up:

zip -r test.zip *.php > /dev/null &
clear
printf "\x1b[5mZipping...\x1b[25m"
wait $!
clear
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.