Shell Scripting

1) for loop
1.1) Simple for loop
# for i in `seq 1 3`
> do
> echo "i is $i"
> done
i is 1
i is 2
i is 3


# for i in 192.168.0.{1..5}
> do
> echo "i is $i"
> done
i is 192.168.0.1
i is 192.168.0.2
i is 192.168.0.3
i is 192.168.0.4
i is 192.168.0.5

# ls
dir1 dir2 file1 file2
# for i in `ls`
> do
> echo "i is $i"
> done
i is dir1
i is dir2
i is file1
i is file2

2) set command
# date
Sun Apr 12 22:41:37 IST 2009

# set `date`
# echo $#
6
# echo $1
Sun
# echo $2
Apr
# echo $3
12
# echo $4
22:41:37
# echo $5
IST
# echo $6
2009

No comments:

Books I like

  • Inside C++ Object Model
  • Unix Network Programming - Stevens
  • Professional-c++-programmer-to-programmer - wrox
  • Beautiful-code-leading-programmers-explain-how-they-think-theory-in-practice