grep

wangshumin@CentOSNode3 shell]$ vim  shelltest4
[wangshumin@CentOSNode3 shell]$ ./shelltest4
input1:1
input2:1
sum is  2
[wangshumin@CentOSNode3 shell]$ vim  shelltest4
[wangshumin@CentOSNode3 shell]$ ./shelltest4
input1:1
input2:2
sum is  3
sum is  1+2
[wangshumin@CentOSNode3 shell]$ cat shelltest4
#!/bin/bash
read -p "input1:" -t 30 num1
read -p "input2:" -t 30 num2
sum1=$(($num1+$num2))
sum2=$num1+$num2
echo "sum is  $sum1"
echo "sum is  $sum2"
[wangshumin@CentOSNode3 shell]$ rz
z waiting to receive.**B0100000023be50
[wangshumin@CentOSNode3 shell]$ ll
总用量 20
-rwxrw-r--. 1 wangshumin wangshumin  41 3月  10 04:37 shelltest1
-rwxr-xr-x. 1 wangshumin wangshumin 189 3月  10 05:53 shelltest2
-rwxr-xr-x. 1 wangshumin wangshumin  66 3月  10 05:57 shelltest3
-rwxrw-r--. 1 wangshumin wangshumin 151 3月  10 06:05 shelltest4
-rw-r--r--. 1 wangshumin wangshumin 188 8月  28 2013 test_rule.txt
[wangshumin@CentOSNode3 shell]$ grep -v "shen" test_rule.txt 
Li Ming said:


he was the most honest man in Xiongdilian. 








he never said those words.


5555






Because,actually,


Shen Chao is the most honest man.
[wangshumin@CentOSNode3 shell]$ grep  "shen" test_rule.txt 
But since shen Chaooo came,
[wangshumin@CentOSNode3 shell]$ grep -n "shen" test_rule.txt 
7:But since shen Chaooo came,
[wangshumin@CentOSNode3 shell]$ rz
z waiting to receive.**B0100000023be50
[wangshumin@CentOSNode3 shell]$ ll
总用量 36
-rwxrw-r--. 1 wangshumin wangshumin    41 3月  10 04:37 shelltest1
-rwxr-xr-x. 1 wangshumin wangshumin   189 3月  10 05:53 shelltest2
-rwxr-xr-x. 1 wangshumin wangshumin    66 3月  10 05:57 shelltest3
-rwxrw-r--. 1 wangshumin wangshumin   151 3月  10 06:05 shelltest4
-rw-r--r--. 1 wangshumin wangshumin   188 8月  28 2013 test_rule.txt
-rw-r--r--. 1 wangshumin wangshumin 15598 4月  12 2012 Tetris.sh
[wangshumin@CentOSNode3 shell]$ grep -n "[a-z]" test_rule.txt 
1:Li Ming said:
3:he was the most honest man in Xiongdilian. 
7:But since shen Chaooo came,
9:he never said those words.
15:Because,actually,
17:Shen Chao is the most honest man.
[wangshumin@CentOSNode3 shell]$ grep -n .grep  "shen" test_rule.txt 
But since shen Chaooo came,
[wangshumin@CentOSNode3 shell]$ 
[wangshumin@CentOSNode3 shell]$ grep -n "[^a-z]" test_rule.txt 
















17:Shen Chao is the most honest man.
[wangshumin@CentOSNode3 shell]$ grep -n "[\.$]" test_rule.txt 
3:he was the most honest man in Xiongdilian. 
9:he never said those words.
17:Shen Chao is the most honest man.
[wangshumin@CentOSNode3 shell]$ grep -n -v "[\.$]" test_rule.txt 
1:Li Ming said:
2:
4:
5:
6:
7:But since shen Chaooo came,
8:
10:
11:5555
12:
13:
14:
15:Because,actually,
16:
[wangshumin@CentOSNode3 shell]$ grep -n "[\.$]" test_rule.txt 
3:he was the most honest man in Xiongdilian. 
9:he never said those words.
17:Shen Chao is the most honest man.
[wangshumin@CentOSNode3 shell]$ grep -n "^$" test_rule.txt 
2:
5:
6:
8:
10:
13:
14:
16:
[wangshumin@CentOSNode3 shell]$ grep -n "oo*" test_rule.txt 
3:he was the most honest man in Xiongdilian. 
7:But since shen Chaooo came,
9:he never said those words.
17:Shen Chao is the most honest man.
[wangshumin@CentOSNode3 shell]$ grep -n "o*" test_rule.txt 
1:Li Ming said:
2:
3:he was the most honest man in Xiongdilian. 
4:
5:
6:
7:But since shen Chaooo came,
8:
9:he never said those words.
10:
11:5555
12:
13:
14:
15:Because,actually,
16:
17:Shen Chao is the most honest man.
[wangshumin@CentOSNode3 shell]$ grep -n "ooo*" test_rule.txt 
7:But since shen Chaooo came,
[wangshumin@CentOSNode3 shell]$ grep -n "oo*" test_rule.txt 
3:he was the most honest man in Xiongdilian. 
7:But since shen Chaooo came,
9:he never said those words.
17:Shen Chao is the most honest man.
[wangshumin@CentOSNode3 shell]$ 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值