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

Re: how to check 400 files exist



>> On Thu, 19 Jan 2012 00:34:50 +0800, 
>> lina <lina.lastname@gmail.com> said:

L> I am choked by how to check more than 400 files exist or not, if not,
L> sleep, but once it's all generated, continue do something.  Those files
L> have a common feature: sys_em_$i.txt

   The script below doesn't do any glob-expansion of filenames, so it won't
   barf if you have a lot of files.  It assumes you're in the same directory
   as the files you're checking.

-- 
Karl Vogel                      I don't speak for the USAF or my company

A raccoon tangled with a 23,000 volt line today.  The results blacked
out 1400 homes and, of course, one raccoon.            --Steel City News

--------------------------------------------------------------------------
#!/bin/bash
export PATH=/usr/local/bin:/bin:/usr/bin

case "$#" in
    0) echo need a number; exit 1 ;;
    *) my_number=$1 ;;
esac

while :
do
    if [ $(find . -name 'sys_em_*.txt' -print | wc -l) == "$my_number" ]
    then
        echo 'success'
        break
    fi

    echo 'test'
    sleep 5
done

echo 'done'
exit 0


Reply to: