tr 替换 删除 sed的小弟 只能单对单的替换
选项:
-d #删除指定的字符
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
语法: tr old new < file < #标准输入重定向 [root@qls ~]# cat test.txt root:x:0:0:root:/root:/bin/bash [root@qls ~]# tr "0" "9" < test.txt root:x:9:9:root:/root:/bin/bash [root@qls ~]# tr -d "o" < test.txt rt:x:0:0:rt:/rt:/bin/bash [root@qls ~]# [root@qls ~]# ip a s eth0 2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000 link/ether 00:0c:29:eb:ea:8d brd ff:ff:ff:ff:ff:ff inet 10.0.0.100/24 brd 10.0.0.255 scope global noprefixroute eth0 valid_lft forever preferred_lft forever inet6 fe80::3310:9d15:9ee4:43e8/64 scope link noprefixroute valid_lft forever preferred_lft forever [root@qls ~]# ip a s eth0 | head -3 | tail -1 inet 10.0.0.100/24 brd 10.0.0.255 scope global noprefixroute eth0 [root@qls ~]# ip a s eth0 | head -3 | tail -1 | tr '/' ' ' inet 10.0.0.100 24 brd 10.0.0.255 scope global noprefixroute eth0 [root@qls ~]# ip a s eth0 | head -3 | tail -1 | tr '/' ' ' | cut -d " " -f6 10.0.0.100 |