您的位置:首页 > 运维架构 > Shell

shell命令

2015-10-17 18:28 344 查看
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为结尾的字母;
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: