Jump to content

unix while loop help


Recommended Posts

Posted

I need to wait for a n number of files to appear before coming out of the loop. filename will be wildcard

files unnayo levo teluskodaniki i figured it out.. but naku certain number of files untene proceed avvadam elano teliyatle..

my current logic 

while [ ! -f #Path#/Temp/Trigger_#Tag#_* ]; do sleep 2 ; done ; echo 0

 

but naku files equal to certain number untene povali ante etlaa..

Posted
30 minutes ago, mettastar said:

I need to wait for a n number of files to appear before coming out of the loop. filename will be wildcard

files unnayo levo teluskodaniki i figured it out.. but naku certain number of files untene proceed avvadam elano teliyatle..

my current logic 

while [ ! -f #Path#/Temp/Trigger_#Tag#_* ]; do sleep 2 ; done ; echo 0

 

but naku files equal to certain number untene povali ante etlaa..

    @yomama  ki message cheyi bro ..... he may help you 

Posted

Probably not a sophisticated way but this will do what you are looking for

 

#!/bin/ksh

matcond=1
descount=10 ##assuming you need 10 files
while [ $matcond == 1 ]
do
ls -ltr *touch* > tempfile
count=$(wc -l < tempfile)
echo $count
if [ $count -eq $descount ]
then matcond=2
else
sleep 2
fi
done

Posted

got it 

 

while [ ! -f /Temp/Trigger_* ] || [ -f /Temp/Trigger_* ] && [ "$( ls /Temp/Trigger_* 2> /dev/null | wc -l)" -le "2" ]; do echo sleeping ;sleep 2 ; done ; echo 0

 

evarikain use aithadi
 

Posted
1 minute ago, mettastar said:

got it 

 

while [ ! -f /Temp/Trigger_* ] || [ -f /Temp/Trigger_* ] && [ "$( ls /Temp/Trigger_* 2> /dev/null | wc -l)" -le "2" ]; do echo sleeping ;sleep 2 ; done ; echo 0

 

evarikain use aithadi
 

yourock 

Posted
6 minutes ago, dkchinnari said:

Umcle nee unix lolli endhi..nu datastage ghaa

DS lo using vuncle

Posted
52 minutes ago, yomama said:

uncle db lo notifications ravu, but someone already answered u query i guess

inka easy solution emina undhaa bro deeniki .... 

Posted
3 hours ago, Tesla said:

Probably not a sophisticated way but this will do what you are looking for

 

#!/bin/ksh

matcond=1
descount=10 ##assuming you need 10 files
while [ $matcond == 1 ]
do
ls -ltr *touch* > tempfile
count=$(wc -l < tempfile)
echo $count
if [ $count -eq $descount ]
then matcond=2
else
sleep 2
fi
done

Dont want to write a script bro.. inline lo chedham ani. i got it. thanks though

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...