Friday, May 8, 2009

Shell script commands

It is similar to batch programming.

PRINT ON THE SCREEN

echo "Hello"

WRITE TO A FILE

echo "Hello" > file.txt

APPEND TO A FILE

echo "Hello" >> file.txt

TAKE INPUT FROM KEYBOARD

read d (some variable d)

EXAMPLE ON FOR LOOP

for d in 1 2 4 f g g d s
do
echo $d
done

EXAMPLE OF WHILE LOOP

n=1
i=1
while [ $i -le 10 ]
do
echo "$n * $i = `expr $i \* $n`"
i=`expr $i + 1`
done

No comments: