How to use for and if?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How to use for and if?
Prev   Next
# 1  
Old 06-06-2017
How to use for and if?

I have a secinario like , want to cat a file until the 123.txt gets empty ....for that i made below syntax, but looks not correct

HTML Code:
cat 123.txt

ram
suresh
John
PHP Code:
for chat in $(cat /tmp/t123.txthead -1)
do
call=`grep -i incoming /home/$chat | wc -l `
if [ -
"$call]
then 
echo " got incoming call from $chat "
else 
echo 
"no incoming calls from $chat "
CHK=$(cat /tmp/t123.txt )
printf "1d\nw\nq\n" ed -s $CHK
                  
if [ $CHK -ge 1 ]
            
then
            chat 
++
            else 
                exit 
0
               fi 

done 
My required o/p would be

HTML Code:
got incoming call from ram
got incoming calls from suresh
got incoming calls from John
Note: new to shell scripting , trying afte longtime Smilie ... so appericiate your help here
 
Login or Register to Ask a Question

Previous Thread | Next Thread
Login or Register to Ask a Question