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

Re: how to check 400 files exist



On 01/19/12 11:45, Jon Dowland wrote:
On 19/01/12 11:29, Wawrzek Niewodniczanski wrote:
On 01/19/12 03:04, lina wrote:

[...]
Thanks,
but here it complains so many $ ./check_file.sh
./check_file.sh: line 8: [: too many arguments

Possible problem with spaces. This one works for me:
No, the problem is the number of arguments to the ls call.
There is a limited number of arguments for a process, and
the glob sys_em_*.txt expanded to more than that number.

What is the number? I tried it with 8192 files:

    #>ls -1 file-* | wc
    -l                                                                 
    
8192
#>../test.sh 8192
sucess                                         

And my script is:

 #>cat ../test.sh
my_number=$1                                                              
while :
do
  if [ `ls -1 file* | wc -l` == "$my_number" ]
  then
    echo "sucess"
    break
  fi
  echo "test"
  sleep 5
done


--
Wawrzyniec (Wawrzek) Niewodniczański - (niewod @ LinkedIn)
System Administrator - Engineering Services Team (XenServer)
Citrix Systems, Building 101, Cambridge Science Park, CB4 0FY, Cambridge
PhD in Quantum Chemistry, MSc in Molecular EngineeringM

Reply to: