ITPub博客

首页 > Linux操作系统 > Linux操作系统 > linux之shell 其他

linux之shell 其他

原创 Linux操作系统 作者:liqilin0429 时间:2011-01-24 14:31:26 0 删除 编辑

 去除重复出现的字符
oracle@ser168:~/qilin/demo> cat oops.txt
And the cowwwwws went homeeeeeeeeeeeeeeeeeeeeeeeee
Or did theYYYYYYYYYYYYYYYYYYYYYYYYYYYYY
oracle@ser168:~/qilin/demo> tr -s "[a-z],[A-Z]"And the cows went home
Or did theY
 删除空行
oracle@ser168:~/qilin/demo> cat plane.txt
kfalfkafa sdfadfa


dfaflakfalf liqilin

43314141 zhuauang

fdafaflaf  dfafkalf

5422422  li
oracle@ser168:~/qilin/demo> tr -s "[\012]" kfalfkafa sdfadfa
dfaflakfalf liqilin
43314141 zhuauang
fdafaflaf  dfafkalf
5422422  li

oracle@ser168:~/qilin/demo> tr -s ["\n"] kfalfkafa sdfadfa
dfaflakfalf liqilin
43314141 zhuauang
fdafaflaf  dfafkalf
5422422  li

 大写到小写
oracle@ser168:~/qilin/demo> cat oops.txt
And the cowwwwws went homeeeeeeeeeeeeeeeeeeeeeeeee
Or did theYYYYYYYYYYYYYYYYYYYYYYYYYYYYY
oracle@ser168:~/qilin/demo> cat oops.txt | tr "[A-Z]" "[a-z]" >lower_oopst.txt
oracle@ser168:~/qilin/demo> cat lower_oopst.txt
and the cowwwwws went homeeeeeeeeeeeeeeeeeeeeeeeee
or did theyyyyyyyyyyyyyyyyyyyyyyyyyyyyy
小写到大写
oracle@ser168:~/qilin/demo> cat oops.txt
And the cowwwwws went homeeeeeeeeeeeeeeeeeeeeeeeee
Or did theYYYYYYYYYYYYYYYYYYYYYYYYYYYYY
oracle@ser168:~/qilin/demo> cat oops.txt | tr "[a-z]" "[A-Z]" >upper_oopst.txt
oracle@ser168:~/qilin/demo> cat upper_oopst.txt
AND THE COWWWWWS WENT HOMEEEEEEEEEEEEEEEEEEEEEEEEE
OR DID THEYYYYYYYYYYYYYYYYYYYYYYYYYYYYY

 删除指定字符
oracle@ser168:~/qilin/demo> cat diary.txt
monday 10:50
Tuserday 15:50
wednesday 12;30
THURDAY 10;20
Friday 06:34
oracle@ser168:~/qilin/demo> tr -cs "[a-z][A-Z]" "[\012*]" monday
Tuserday
wednesday
THURDAY
Friday
 转换控制字符

 去除重复出现的字符
oracle@ser168:~/qilin/demo> cat oops.txt
And the cowwwwws went homeeeeeeeeeeeeeeeeeeeeeeeee
Or did theYYYYYYYYYYYYYYYYYYYYYYYYYYYYY
oracle@ser168:~/qilin/demo> tr -s "[a-z],[A-Z]"And the cows went home
Or did theY
 删除空行
oracle@ser168:~/qilin/demo> cat plane.txt
kfalfkafa sdfadfa


dfaflakfalf liqilin

43314141 zhuauang

fdafaflaf  dfafkalf

5422422  li
oracle@ser168:~/qilin/demo> tr -s "[\012]" kfalfkafa sdfadfa
dfaflakfalf liqilin
43314141 zhuauang
fdafaflaf  dfafkalf
5422422  li

oracle@ser168:~/qilin/demo> tr -s ["\n"] kfalfkafa sdfadfa
dfaflakfalf liqilin
43314141 zhuauang
fdafaflaf  dfafkalf
5422422  li

 大写到小写
oracle@ser168:~/qilin/demo> cat oops.txt
And the cowwwwws went homeeeeeeeeeeeeeeeeeeeeeeeee
Or did theYYYYYYYYYYYYYYYYYYYYYYYYYYYYY
oracle@ser168:~/qilin/demo> cat oops.txt | tr "[A-Z]" "[a-z]" >lower_oopst.txt
oracle@ser168:~/qilin/demo> cat lower_oopst.txt
and the cowwwwws went homeeeeeeeeeeeeeeeeeeeeeeeee
or did theyyyyyyyyyyyyyyyyyyyyyyyyyyyyy
小写到大写
oracle@ser168:~/qilin/demo> cat oops.txt
And the cowwwwws went homeeeeeeeeeeeeeeeeeeeeeeeee
Or did theYYYYYYYYYYYYYYYYYYYYYYYYYYYYY
oracle@ser168:~/qilin/demo> cat oops.txt | tr "[a-z]" "[A-Z]" >upper_oopst.txt
oracle@ser168:~/qilin/demo> cat upper_oopst.txt
AND THE COWWWWWS WENT HOMEEEEEEEEEEEEEEEEEEEEEEEEE
OR DID THEYYYYYYYYYYYYYYYYYYYYYYYYYYYYY

 删除指定字符
oracle@ser168:~/qilin/demo> cat diary.txt
monday 10:50
Tuserday 15:50
wednesday 12;30
THURDAY 10;20
Friday 06:34
oracle@ser168:~/qilin/demo> tr -cs "[a-z][A-Z]" "[\012*]" monday
Tuserday
wednesday
THURDAY
Friday
 转换控制字符

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/20976446/viewspace-684542/,如需转载,请注明出处,否则将追究法律责任。

下一篇: linux 之远程复制
请登录后发表评论 登录
全部评论

注册时间:2010-08-13

  • 博文量
    100
  • 访问量
    202439