|
| From: | Chris Elvidge |
| Subject: | Re: wait until the file is done |
| Date: | Sat, 31 Oct 2020 18:15:16 +0000 |
| User-agent: | Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1 Lightning/5.4 |
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
| [Prev in Thread] | Current Thread | [Next in Thread] |