tr -[dsx] seting ...
使用tr替换字符:
| 
       1
       
       2
       
       3
       
       4
       
       5
       
       6
       
       7
       
       8
       
       9
       
       10
       
       11
       
       12
       | [whx@localhost ~]$ last | head-n 5 | tr'[a-z]''[A-Z]'WHX     PTS/0192.168.21.1     SUN AUG 27 18:22   STILL LOGGED IN  REBOOT  SYSTEM BOOT  2.6.32-696.EL6.X SUNAUG 27 18:21 - 00:39  (06:18)   WHX     PTS/0192.168.21.1     THU AUG 24 18:37 - 02:54  (08:17)   WHX     TTY1         :0               THU AUG 24 18:36 - DOWN   (08:18)   REBOOT  SYSTEM BOOT  2.6.32-696.EL6.X THUAUG 24 18:35 - 02:55  (08:19)   [whx@localhost ~]$ last | head-n 5whx     pts/0192.168.21.1     Sun Aug 27 18:22   still logged inreboot  system boot  2.6.32-696.el6.x SunAug 27 18:21 - 00:39  (06:18)   whx     pts/0192.168.21.1     Thu Aug 24 18:37 - 02:54  (08:17)   whx     tty1         :0               Thu Aug 24 18:36 - down   (08:18)   reboot  system boot  2.6.32-696.el6.x ThuAug 24 18:35 - 02:55  (08:19) | 
添加-d参数删除字符:
| 
       1
       
       2
       
       3
       
       4
       
       5
       
       6
       
       7
       
       8
       
       9
       
       10
       
       11
       
       12
       | [whx@localhost ~]$ cat/etc/passwd|head-n5root:x:0:0:root:/root:/bin/bashbin:x:1:1:bin:/bin:/sbin/nologindaemon:x:2:2:daemon:/sbin:/sbin/nologinadm:x:3:4:adm:/var/adm:/sbin/nologinlp:x:4:7:lp:/var/spool/lpd:/sbin/nologin[whx@localhost ~]$ cat/etc/passwd|head-n5 |tr-d ':'rootx00root/root/bin/bashbinx11bin/bin/sbin/nologindaemonx22daemon/sbin/sbin/nologinadmx34adm/var/adm/sbin/nologinlpx47lp/var/spool/lpd/sbin/nologin | 
添加-s参数去除重复字符:
| 
       1
       
       2
       | [whx@localhost ~]$ echo'thissss   issss aaaa test'|tr-s 'sa'this  is a  test | 
col常用于将man page转存为纯文本文件以方便查阅。
col -x 将tab替换成对等的空格键
| 
       1
       
       2
       
       3
       
       4
       
       5
       
       6
       
       7
       
       8
       
       9
       
       10
       
       11
       
       12
       
       13
       
       14
       
       15
       
       16
       
       17
       
       18
       
       19
       
       20
       
       21
       
       22
       | [whx@localhost ~]$ cat/etc/man.config | tail-10 | col -x |cat-A|tail-10#$# Enable/disable makewhatis database cronupdates.$# If MAKEWHATISDBUPDATES variable isuncommented$# and set to n or N, cron scripts$# /etc/cron.daily/makewhatis.cron$# /etc/cron.weekly/makewhatis.cron$# will not update makewhatis database.$# Otherwise the database will be updated.$#$#MAKEWHATISDBUPDATES    n$[whx@localhost ~]$ cat/etc/man.config | tail-10 | cat-A#$# Enable/disable makewhatis database cronupdates.$# If MAKEWHATISDBUPDATES variable isuncommented$# and set to n or N, cron scripts $# /etc/cron.daily/makewhatis.cron$# /etc/cron.weekly/makewhatis.cron$# will not update makewhatis database.$# Otherwise the database will be updated.$# $#MAKEWHATISDBUPDATES^In$ | 
expand转换指令:
expand [-t] file
使用-t参数设置使用6个空格键代替tab键(默认使用8个空格键代替tab键)
| 
       1
       
       2
       
       3
       
       4
       
       5
       
       6
       
       7
       
       8
       | [whx@localhost ~]$ grep'^MANPATH'/etc/man.config |head-n 3 | expand-t 6 |cat-AMANPATH    /usr/man$MANPATH    /usr/share/man$MANPATH    /usr/local/man$[whx@localhost ~]$ grep'^MANPATH'/etc/man.config |head-n 3 | cat-AMANPATH^I/usr/man$MANPATH^I/usr/share/man$MANPATH^I/usr/local/man$ | 
 
  本文转自 天黑顺路 51CTO博客,原文链接:http://blog.51cto.com/mjal01/1960194,如需转载请自行联系原作者
  
 
 
 
