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: Sun, 1 Nov 2020 12:37:30 +0100

Thank you Chris!
I modifed the function as per your suggestion.
I tried it and it worked well.

How I should increase its verbosity?

[ -e "$1" ] || echo 'No such file'; return 1

Is this any good?

On 20-10-31 18:15:16, Chris Elvidge wrote:
> On 31/10/2020 04:13 pm, MN wrote:
> > I thought I would make the function typo-proof.
> > Is this how it should be done?
> > 
> > waitfor() {
> > oldsize=0
> > if [[ -e "$1" ]]; then         #new lines
> >      while sleep 30; do
> >      size=$(wc -c < "$1")
> >      if ((size > oldsize)); then
> >          oldsize=$size
> >          SECONDS=0
> >          continue
> >      fi
> >      if ((SECONDS > 600)); then
> >          break
> >      fi
> >      done
> > else                           #new lines
> >      echo 'No such file'        #new lines
> > fi
> > }
> > 
> > 
> 
> waitfor() {
>       # return error if $1 not exists
>       [ -e "$1" ] || return 1
>       oldsize=0
>       size=$(wc -c <"$1")
>       # check if size increased in last 30 seconds
>       while ((size>oldsize)); do
>               oldsize=$size
>               sleep 30
>               size=$(wc -c <"$1")
>       done
> }
> 
> 
> -- 
> Chris Elvidge
> England



reply via email to

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