Monday, May 27, 2013

A simple example of shell script

#!/bin/bash
for n in 1 2 3 4 'str1' 'str2' ; do
 echo i $n
done

for (( n=1; n<10; n++ )); do
  echo n $n
done

count=10
while [ $count -le 20 ]; do
  echo count $count
  count=`expr $count + 1`
done


opt=2
case "$opt" in
  "1")
     echo "case1"
     ;;
  "2")
     echo "case2"
     ;;
   *)
     echo "*"
     ;;
esac

echo $(( 1+2 ))
let x='1+2'; echo $x
echo `expr 1 + 2`

No comments:

Post a Comment