shell命令

来源:互联网 发布:mac 10.12.6系统怎么样 编辑:程序博客网 时间:2024/06/07 10:23

shell命令之sed命令 我感觉sed最有用的命令是修改字符串的命令;

比如 this is first;

执行sed "s/is/IS/" 1.txt;

这时就变成了thIS IS first;这里会把is改成IS

还有这个命令:

this is first 

this is second

this is three

这里使用命令sed "1 c/ 中国" 1.txt现在就变成了;

中国

this is second

this is three

还有这个命令:

this is first 

this is second 

this is three

这命令里使用sed "2 a/ 中国" 1.txt现在就变成了:

this is first 

this is second 

中国

this is three

还有这个命令:

this is first

this is second

this is three

这里使用sed "2 i/中国" 1.txt现在就变成了:

this is first

中国

this is second

this is three

grep 命令

grep "[a-z][a-z][a-z]L" 1.txt

grep是字符串匹配命令

这里匹配的是第一个字母是a-z中的随意一个字母第二个字母是a-z中的随意中的一个第三个字母同样的道理

以L位结尾这里一共可以匹配的是26*26*26中情况;

grep "正则表达式" 1.txt

正则表达式 regular  expression 

grep "p$" 1.txt匹配出以p为结尾的字母;

0 0
原创粉丝点击