Ksh Tutorials :for loop in kshell programming

Ksh Tutorials :for loop in kshell programming
while do done
while [[ $count -gt 0 ]];do
print "\$count is $count"
(( count -= 1 ))
done
until do done
until [[ $answer = "yes" ]];do
print -n "Please enter \"yes\": "
read answer
print ""
done
for var in list do done
for foo in $(ls);do
if [[ -d $foo ]];then
print "$foo is a directory"
else
print "$foo is not a directory"
fi
done
continue...break
One can skip the rest of a loop and directly go to the next iteration with: "continue".
while read line
do
if [[ $line = *.gz ]];then
continue
else
print $line
fi
done
One can also prematurely leave a loop with: "break".
while read line;do
if [[ $line = *!(.c) ]];then
break
else
print $line
fi
done

No comments:

 
Top Blogs