Shell Scripting Tutorial-2: Shell, Kernel, Terminal & More

cal

cal 7 2006

date

[root@usdalwm9 ~]# date '+DATE:%m-%y%nTIME:%H:%M:%S'
DATE:11-13
TIME:04:49:30

[root@usdalwm9 ~]# a=3.5
[root@usdalwm9 ~]# a=11.4
[root@usdalwm9 ~]# expr $a / $b|bc
expr: non-numeric argument
[root@usdalwm9 ~]# expr $a/$b|bc
3
[root@usdalwm9 ~]# expr $a/$b
11.4/3
[root@usdalwm9 ~]# expr $a/$b|bc
3
[root@usdalwm9 ~]# expr $a + $b
expr: non-numeric argument
[root@usdalwm9 ~]# expr $a + $b|bc
expr: non-numeric argument
[root@usdalwm9 ~]# expr $a+$b|bc
14.4
[root@usdalwm9 ~]# a=4
[root@usdalwm9 ~]# expr $a + $b
7
[root@usdalwm9 ~]# expr $a+$b
4+3

for word in str

do

done

util []

do

done

while []

do

done

 

 

 

[root@usdalwm9 ~]# sh ct.sh
Enter a filename
test
NUMBER of LInes:14
NUMBER of words:17
[root@usdalwm9 ~]# cat ct.sh
umask 0022
echo "Enter a filename"
read fname
terminal=`tty`
exec < $fname

nol=0

now=0

while read line
do

        nol=`expr $nol + 1`
        set $line
        now=`expr $now + $#`
done

echo "NUMBER of LInes:$nol"
echo "NUMBER of words:$now"

exec <$terminal

case $var in [a-z]*|[678]* do;; [A..Z] do;; ?) do ;; esac
 
[root@usdalwm9 ~]# seq 1 3
1
2
3
[root@usdalwm9 ~]# seq 1 3 6
1
4
[root@usdalwm9 ~]# seq 0 2 10
0
2
4
6
8
10
[root@usdalwm9 ~]# seq 0 2 4
0
2
4
[root@usdalwm9 ~]# seq 1 3
1
2
3
[root@usdalwm9 ~]# echo {1..c}
{1..c}
[root@usdalwm9 ~]# echo {a..c}
a b c
[root@usdalwm9 ~]# mkdir -p test/{1..2}/{1..2}
mkdir: cannot create directory `test': Not a directory
mkdir: cannot create directory `test': Not a directory
mkdir: cannot create directory `test': Not a directory
mkdir: cannot create directory `test': Not a directory
[root@usdalwm9 ~]# mkdir -p ./{1..2}/{1..2}
mkdir: cannot create directory `./1': Not a directory
mkdir: cannot create directory `./1': Not a directory
 
[root@usdalwm9 ~]# for i in {3..1};do echo $i ;done
3
2
1
 
 
 
 
 
 
 
 
 
 
 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值