C-style while loop:
#!/bin/bash # wh-loopc.sh: Count to 10 in a "while" loop. LIMIT=10 a=1 while [ "$a" -le $LIMIT ] do echo -n "$a " let "a+=1" done # No surprises, so far. echo; echo # +=================================================================+ # Now, repeat with C-like syntax. # Double parentheses permit space when setting a variable, as in C. ((a = 1)) # a=1 # Double parentheses, and no "$" preceding variables. while (( a <= LIMIT )) do echo -n "$a " ((a += 1)) # Double parentheses permit incrementing a variable with C-like syntax. done exit 0 # +=================================================================+ # reading a file line by line while read line do echo "${line}" done < ./straddle.prop
No comments:
Post a Comment