help-bash
[Top][All Lists]
Advanced

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

Re: wait until the file is done


From: MN
Subject: Re: wait until the file is done
Date: Fri, 30 Oct 2020 22:43:45 +0100

Thank you so much for your help.
I chose what Greg Wooledge suggested.
(inotify-tools package is currently not available on my machine.)

This is how the function looks like:
I somewhat touched it, so let me know if I seriously messed it up.
(The numbers are lowered for testing purposes
and the echo will be removed too)

  waitfor() { 
  oldsize=0

  while sleep 3; do
    size=$(wc -c < "$1")
    if ((size > oldsize)); then
      oldsize=$size
      SECONDS=0
      echo 'new loop'
      continue
    fi
    if ((SECONDS > 10)); then
      break
    fi
  done
  }

It worked as expected. As soon as the video was processed, there was no 
more 'new loop' lines and I got my prompt back in 10s.

(Shutdown line was removed from the function. I prefer to add it 
manually in case I want to do different task, like hibernating)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]