Jeff Abrahamson on Sun, 12 May 2002 11:50:16 +0200


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

Re: [PLUG] can i fork a process in the bash shell?


On Sat, May 11, 2002 at 01:43:50PM -0400, Nick Rongione wrote:
> Specifically, I want to kick off a delete of a huge directory and in
> the mean time interact with the user a bit more. Only when i know the
> delete is complete I want to continue doing the rest of the script
> actions.  
> 
> I don't know how to pull that off in bash. Any help would be appreciated.

Fred proposed looping on a ps, which would surely work.

You might also do something like the following:

    tmp=/tmp/foo.$$.`date +%Y%m%d%H%M%s`
    rm -rf $dir $tmp &
    do_stuff
    while [ -r $tmp ]; do sleep 1; done
    do_more_stuff

The rm will remove the directory first, then move on to its second
argument. This may not be entirely portable, as some rm implementation
somewhere may just perversely unlink its arguments in reverse order.

-- 
 Jeff

 Jeff Abrahamson  <http://www.purple.com/jeff/>

 The Big Book of Misunderstanding, now in bookstores and on the web:
 <http://www.misunderstanding.net/buystuff.html>

Attachment: pgppHZYCYidai.pgp
Description: PGP signature