find sed sort wc 20140804

find /home/tolstoy -typed d -print                    |寻找所有目录

 sed  's; /home/tolstoy/;/home/lt/;'                    |修改名称这里用分号作为界定符

sed 's/^/mkdir /'                                                   |插入 mkdir 命令

sh -X                                                                      以shell 命令跟踪模式执行

上述脚本是将/home/tolstoy 目录结构建立一份副本在/home/lt 下

~$ echo tolstoy reads well. tolstoy writes well. > example.txt
siat@siat-HP:~$ sed 's/tolstoy/camus/' < example.txt
camus reads well. tolstoy writes well.
siat@siat-HP:~$ sed 's/tolstoy/camus/g' < example.txt
camus reads well. camus writes well.

如果没有设置g (global) 即替代文本取代正则表达式中每个匹配的‘

sed 's/tolstoy/camus/2' < example.txt
tolstoy reads well. camus writes well.

只匹配第二个

echo abc | sed 's/b*/1/'                     替代第一个匹配成功的 包括NULL字符
1abc
siat@siat-HP:~$ echo abc | sed 's/b*/1/g'       替代所有匹配成功的
1a1c1

排序

siat@siat-HP:~$ sort -t_ -k1,1 -k2,2 << EOF
> one_two
> one_two_three
> one_two_four
> one_two_five
> EOF
one_two
one_two_five
one_two_four
one_two_three


计算行数字数及字符数

echo this si a test the hiohoh hiooi hioo | wc
      1       8      37

行数  字数 字符数

echo this si a test the hiohoh hiooi hioo | wc  -c
37
siat@siat-HP:~$ echo this si a test the hiohoh hiooi hioo | wc  -l
1
siat@siat-HP:~$ echo this si a test the hiohoh hiooi hioo | wc  -w
8






  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值