> 技术文档 > Linux730 tr:-d /-s;sort:-r,-n,-R,-o,-t,-k,-u;bash;cut:-d,-c;tee -a;uniq -c -i

Linux730 tr:-d /-s;sort:-r,-n,-R,-o,-t,-k,-u;bash;cut:-d,-c;tee -a;uniq -c -i


回顾

sort

sort [选项] 文件
Linux730 tr:-d /-s;sort:-r,-n,-R,-o,-t,-k,-u;bash;cut:-d,-c;tee -a;uniq -c -i
-u:唯一,去除重复
-r:按数字大小,倒序排序,大到小
-o:输出文件
-n:按数字大小,顺序排序,小到大
-t: -t后加分割符,按分割符为标准,进行筛选
-k:k后加数字,第k列
-R:随机排序
-b:

uniq

uniq [选项] 文件
去除连续的重复行
Linux730 tr:-d /-s;sort:-r,-n,-R,-o,-t,-k,-u;bash;cut:-d,-c;tee -a;uniq -c -i
-i:忽略大小写
-c:统计重复行次数

[root@web ~]# uniq 1.txtuniq: 1.txt: 没有那个文件或目录您在 /var/spool/mail/root 中有邮件[root@web ~]# cd /tmp[root@web tmp]# uniq 1.txt112:2223:33321312:3:2:1:312:3123123123213123:1232112:123:!@#:!@#:@!:!@#!@:#:!@#:!@:#!@:21312312:S:ADAS:D:!@:#!@:#:@!#:!@#!@12312312123122121312312:!@#!@#!#AS:ASDSAD:!@#!@#:ASDASD:!@#@!213123::::!@#@!#:@!#213:@!#12123123:!@#213:!@#123:!@#!@#:!#!@#:123123:@!3123213213:12312:!@#!@:!@312:!@3123:!@312:!@#12:21321312:!23123:!@3123213232131232132312312312312312312312312321312312321312312312123123[root@web tmp]# uniq -c 1.txt 1 112:2223:333213 1 12:3:2:1:312:3123 1 123123213123:123 1 2112:123:!@#:!@#:@!:!@#!@:#:!@#:!@:#!@: 1 21312312:S:ADAS:D:!@:#!@:#:@!#:!@#!@ 1 12312312123122121312312:!@#!@#!#AS:ASDSAD:!@#!@#:ASDASD:!@#@! 1 213123::::!@#@!#:@!#213:@!#12 1 123123:!@#213:!@#123:!@#!@#:!#!@#:123123:@!3123 1 213213:12312:!@#!@:!@312:!@3123:!@312:!@#12:21321312:!23123:!@3 1 123213 1 2 1 3213123 1 21 1 32 1 312 1 3 1 12312312312 1 3 1 123123123213 1 1 12312321 1 312312312 1 123123[root@web tmp]# uniq -i 1.txt112:2223:33321312:3:2:1:312:3123123123213123:1232112:123:!@#:!@#:@!:!@#!@:#:!@#:!@:#!@:21312312:S:ADAS:D:!@:#!@:#:@!#:!@#!@12312312123122121312312:!@#!@#!#AS:ASDSAD:!@#!@#:ASDASD:!@#@!213123::::!@#@!#:@!#213:@!#12123123:!@#213:!@#123:!@#!@#:!#!@#:123123:@!3123213213:12312:!@#!@:!@312:!@3123:!@312:!@#12:21321312:!23123:!@3123213232131232132312312312312312312312312321312312321312312312123123

tee

双重覆盖重定向
命令 | tee 文件
-a:双重追加重定向
cat 1.txt |tee 4.txt
echo hello world | tee file5

[root@web tmp]# echo hello world | tee file5hello world您在 /var/spool/mail/root 中有邮件[root@web tmp]# cat file5hello world[root@web tmp]#

diff

逐行比较文件不同
-u:
Linux730 tr:-d /-s;sort:-r,-n,-R,-o,-t,-k,-u;bash;cut:-d,-c;tee -a;uniq -c -i
-u:合并格式显示
-c:上下文格式显示

[root@web tmp]# diff 1.txt 2.txt1c1,4< 112:2223:333213--->> 2> 3> 33c6,9< 123123213123:123---> 21> 32> 112:2223:333213> 3125,7c11< 21312312:S:ADAS:D:!@:#!@:#:@!#:!@#!@< 12312312123122121312312:!@#!@#!#AS:ASDSAD:!@#!@#:ASDASD:!@#@!< 213123::::!@#@!#:@!#213:@!#12---> 1231239d12< 213213:12312:!@#!@:!@312:!@3123:!@312:!@#12:21321312:!23123:!@311c14,15< 2---> 213123::::!@#@!#:@!#213:@!#12> 213213:12312:!@#!@:!@312:!@3123:!@312:!@#12:21321312:!23123:!@313,20d16< 21< 32< 312< 3< 12312312312< 3< 123123123213<21a18> 21312312:S:ADAS:D:!@:#!@:#:@!#:!@#!@23c20,23< 123123---> 12312312312> 123123123213> 123123213123:123> 12312312123122121312312:!@#!@#!#AS:ASDSAD:!@#!@#:ASDASD:!@#@![root@web tmp]# diff 2.txt 3.txt1,23c1,27<< 2< 3< 3< 12:3:2:1:312:3123< 21< 32< 112:2223:333213< 312< 2112:123:!@#:!@#:@!:!@#!@:#:!@#:!@:#!@:< 123123< 123123:!@#213:!@#123:!@#!@#:!#!@#:123123:@!3123< 123213< 213123::::!@#@!#:@!#213:@!#12< 213213:12312:!@#!@:!@312:!@3123:!@312:!@#12:21321312:!23123:!@3< 3213123< 12312321< 21312312:S:ADAS:D:!@:#!@:#:@!#:!@#!@< 312312312< 12312312312< 123123123213< 123123213123:123< 12312312123122121312312:!@#!@#!#AS:ASDSAD:!@#!@#:ASDASD:!@#@!---> root:x:0:0:root:/root:/bin/bash> bin:x:1:1:bin:/bin:/sbin/nologin> daemon:x:2:2:daemon:/sbin:/sbin/nologin> adm:x:3:4:adm:/var/adm:/sbin/nologin> lp:x:4:7:lp:/var/spool/lpd:/sbin/nologin> sync:x:5:0:sync:/sbin:/bin/sync> shutdown:x:6:0:shutdown:/sbin:/sbin/shutdown> halt:x:7:0:halt:/sbin:/sbin/halt> mail:x:8:12:mail:/var/spool/mail:/sbin/nologin> operator:x:11:0:operator:/root:/sbin/nologin> games:x:12:100:games:/usr/games:/sbin/nologin> ftp:x:14:50:FTP User:/var/ftp:/sbin/nologin> nobody:x:99:99:Nobody:/:/sbin/nologin> systemd-network:x:192:192:systemd Network Management:/:/sbin/nologin> dbus:x:81:81:System message bus:/:/sbin/nologin> polkitd:x:999:998:User for polkitd:/:/sbin/nologin> libstoragemgmt:x:998:995:daemon account for libstoragemgmt:/var/run/lsm:/sbin/nologin> colord:x:997:994:User for colord:/var/lib/colord:/sbin/nologin> rpc:x:32:32:Rpcbind Daemon:/var/lib/rpcbind:/sbin/nologin> saned:x:996:993:SANE scanner daemon user:/usr/share/sane:/sbin/nologin> gluster:x:995:992:GlusterFS daemons:/run/gluster:/sbin/nologin> aaaaaaaaaaaaaaaaaaaaaa> bbbbbbbbbbbbbbbbbbbbbbb1111111111222222222333333331cccccccccc> hello world 888> 666> 777> 999[root@web tmp]# diff file1 file2[root@web tmp]# diff -c 1.txt 2.txt*** 1.txt 2025-07-28 21:46:59.593951441 +0800--- 2.txt 2025-07-28 21:12:17.477645718 +0800****************** 1,23 ****! 112:2223:333213 12:3:2:1:312:3123! 123123213123:123 2112:123:!@#:!@#:@!:!@#!@:#:!@#:!@:#!@:! 21312312:S:ADAS:D:!@:#!@:#:@!#:!@#!@! 12312312123122121312312:!@#!@#!#AS:ASDSAD:!@#!@#:ASDASD:!@#@!! 213123::::!@#@!#:@!#213:@!#12 123123:!@#213:!@#123:!@#!@#:!#!@#:123123:@!3123- 213213:12312:!@#!@:!@312:!@3123:!@312:!@#12:21321312:!23123:!@3 123213! 2 3213123- 21- 32- 312- 3- 12312312312- 3- 123123123213- 12312321 312312312! 123123--- 1,23 ----!! 2! 3! 3 12:3:2:1:312:3123! 21! 32! 112:2223:333213! 312 2112:123:!@#:!@#:@!:!@#!@:#:!@#:!@:#!@:! 123123 123123:!@#213:!@#123:!@#!@#:!#!@#:123123:@!3123 123213! 213123::::!@#@!#:@!#213:@!#12! 213213:12312:!@#!@:!@312:!@3123:!@312:!@#12:21321312:!23123:!@3 3213123 12312321+ 21312312:S:ADAS:D:!@:#!@:#:@!#:!@#!@ 312312312! 12312312312! 123123123213! 123123213123:123! 12312312123122121312312:!@#!@#!#AS:ASDSAD:!@#!@#:ASDASD:!@#@!您在 /var/spool/mail/root 中有邮件[root@web tmp]#

diff dir1 dr2

[root@web tmp]# diff dir1 dir2只在 dir1 存在:file1只在 dir2 存在:file2您在 /var/spool/mail/root 中有邮件

patch 1.txt file6.patch

diff -uN 1.txt 2.txt > file6.patch
diff -c 1.txt 2.txt
patch 1.txt file6.patch
diff 1.txt 2.txt

[root@web tmp]# diff -uN 5.txt 6.txt--- 5.txt 2025-07-30 20:05:17.378243112 +0800+++ 6.txt 2025-07-30 20:05:24.485368451 +0800@@ -1,23 +1,23 @@-112:2223:333213++2+3+3 12:3:2:1:312:3123-123123213123:123+21+32+112:2223:333213+312 2112:123:!@#:!@#:@!:!@#!@:#:!@#:!@:#!@:-21312312:S:ADAS:D:!@:#!@:#:@!#:!@#!@-12312312123122121312312:!@#!@#!#AS:ASDSAD:!@#!@#:ASDASD:!@#@!-213123::::!@#@!#:@!#213:@!#12+123123 123123:!@#213:!@#123:!@#!@#:!#!@#:123123:@!3123-213213:12312:!@#!@:!@312:!@3123:!@312:!@#12:21321312:!23123:!@3 123213-2+213123::::!@#@!#:@!#213:@!#12+213213:12312:!@#!@:!@312:!@3123:!@312:!@#12:21321312:!23123:!@3 3213123-21-32-312-3-12312312312-3-123123123213- 12312321+21312312:S:ADAS:D:!@:#!@:#:@!#:!@#!@ 312312312-123123+12312312312+123123123213+123123213123:123+12312312123122121312312:!@#!@#!#AS:ASDSAD:!@#!@#:ASDASD:!@#@![root@web tmp]# diff -uN 5.txt 6.txt >file6.patch您在 /var/spool/mail/root 中有邮件[root@web tmp]# patch 5.txt file6.patchpatching file 5.txt您在 /var/spool/mail/root 中有邮件[root@web tmp]# diff 5.txt 6.txt[root@web tmp]# diff -c 5.txt 6.txt[root@web tmp]# diff -u 5.txt 6.txt您在 /var/spool/mail/root 中有邮件[root@web tmp]# cat 5.txt23312:3:2:1:312:31232132112:2223:3332133122112:123:!@#:!@#:@!:!@#!@:#:!@#:!@:#!@:123123123123:!@#213:!@#123:!@#!@#:!#!@#:123123:@!3123123213213123::::!@#@!#:@!#213:@!#12213213:12312:!@#!@:!@312:!@3123:!@312:!@#12:21321312:!23123:!@332131231231232121312312:S:ADAS:D:!@:#!@:#:@!#:!@#!@31231231212312312312123123123213123123213123:12312312312123122121312312:!@#!@#!#AS:ASDSAD:!@#!@#:ASDASD:!@#@![root@web tmp]# cat 6.txt23312:3:2:1:312:31232132112:2223:3332133122112:123:!@#:!@#:@!:!@#!@:#:!@#:!@:#!@:123123123123:!@#213:!@#123:!@#!@#:!#!@#:123123:@!3123123213213123::::!@#@!#:@!#213:@!#12213213:12312:!@#!@:!@312:!@3123:!@312:!@#12:21321312:!23123:!@332131231231232121312312:S:ADAS:D:!@:#!@:#:@!#:!@#!@31231231212312312312123123123213123123213123:12312312312123122121312312:!@#!@#!#AS:ASDSAD:!@#!@#:ASDASD:!@#@!

tr

字符的转换、替换、删除
用法1:tr 文件1 文件2 tr ‘string1’ ‘string2’ < filename
用法2:commands | tr file1 file2 ‘string1’ ‘string2’
用法3:tr options ‘string1’ < filename

-d:删除所有字符
-s:删除重复字符序列,只保留第一个
Linux730 tr:-d /-s;sort:-r,-n,-R,-o,-t,-k,-u;bash;cut:-d,-c;tee -a;uniq -c -i
tr -d ‘[: /]’ < 3.txt 删除3.txt所有的:和/
cat 3.txt |tr -d ‘[: /]’ 删除3.txt 所有的 : 和 /
tr ‘[0-9]’ ‘[@]’ < 3.txt 替换 将3.txt所有的数字替换为@
tr ‘[a-z]’ ‘[A-Z]’ < 3.txt 替换3.txt中所有的小写字母为大写字母
tr -s ‘[a-z0-9]’ < 3.txt 删除3.txt中所有重复的小写字母数字,只保留第一个字母数字
tr -s ‘[a-z]’ < 3.txt 删除3.txt中所有的小写字母
tr -d ‘[:digit:]’ < 3.txt 删除3.txt中所有的数字
tr -d ‘[:blank:]’ < 3.txt 删除3.txt中所有的空格 水平空白
tr -d ‘[:space:]’ < 3.txt 删除3.txt中所有的水平、垂直空白

[root@web tmp]# cat 5.txt23312:3:2:1:312:31232132112:2223:3332133122112:123:!@#:!@#:@!:!@#!@:#:!@#:!@:#!@:123123123123:!@#213:!@#123:!@#!@#:!#!@#:123123:@!3123123213213123::::!@#@!#:@!#213:@!#12213213:12312:!@#!@:!@312:!@3123:!@312:!@#12:21321312:!23123:!@332131231231232121312312:S:ADAS:D:!@:#!@:#:@!#:!@#!@31231231212312312312123123123213123123213123:12312312312123122121312312:!@#!@#!#AS:ASDSAD:!@#!@#:ASDASD:!@#@![root@web tmp]# cat 6.txt23312:3:2:1:312:31232132112:2223:3332133122112:123:!@#:!@#:@!:!@#!@:#:!@#:!@:#!@:123123123123:!@#213:!@#123:!@#!@#:!#!@#:123123:@!3123123213213123::::!@#@!#:@!#213:@!#12213213:12312:!@#!@:!@312:!@3123:!@312:!@#12:21321312:!23123:!@332131231231232121312312:S:ADAS:D:!@:#!@:#:@!#:!@#!@31231231212312312312123123123213123123213123:12312312312123122121312312:!@#!@#!#AS:ASDSAD:!@#!@#:ASDASD:!@#@![root@web tmp]# cat 5.txt | tr -d \'[:/]\'233123213123123213211222233332133122112123!@#!@#@!!@#!@#!@#!@#!@123123123123!@#213!@#123!@#!@#!#!@#123123@!3123123213213123!@#@!#@!#213@!#1221321312312!@#!@!@312!@3123!@312!@#1221321312!23123!@332131231231232121312312SADASD!@#!@#@!#!@#!@3123123121231231231212312312321312312321312312312312312123122121312312!@#!@#!#ASASDSAD!@#!@#ASDASD!@#@!您在 /var/spool/mail/root 中有邮件[root@web tmp]# tr -s [1-9] < 1.txt12:23:321312:3:2:1:312:3123123123213123:123212:123:!@#:!@#:@!:!@#!@:#:!@#:!@:#!@:21312312:S:ADAS:D:!@:#!@:#:@!#:!@#!@1231231212312121312312:!@#!@#!#AS:ASDSAD:!@#!@#:ASDASD:!@#@!213123::::!@#@!#:@!#213:@!#12123123:!@#213:!@#123:!@#!@#:!#!@#:123123:@!3123213213:12312:!@#!@:!@312:!@3123:!@312:!@#12:21321312:!23123:!@3123213232131232132312312312312312312312312321312312321312312312123123[root@web tmp]# tr -s [1-9] <5.txt23312:3:2:1:312:3123213212:23:3213312212:123:!@#:!@#:@!:!@#!@:#:!@#:!@:#!@:123123123123:!@#213:!@#123:!@#!@#:!#!@#:123123:@!3123123213213123::::!@#@!#:@!#213:@!#12213213:12312:!@#!@:!@312:!@3123:!@312:!@#12:21321312:!23123:!@332131231231232121312312:S:ADAS:D:!@:#!@:#:@!#:!@#!@31231231212312312312123123123213123123213123:1231231231212312121312312:!@#!@#!#AS:ASDSAD:!@#!@#:ASDASD:!@#@!您在 /var/spool/mail/root 中有邮件[root@web tmp]# tr \'[1-9]\' \'[@]\' < 5.txt]]]@]:]:]:@:]@]:]@]]]@]]@@]:]]]]:]]]]@]]@]]@@]:@]]:!@#:!@#:@!:!@#!@:#:!@#:!@:#!@:@]]@]]@]]@]]:!@#]@]:!@#@]]:!@#!@#:!#!@#:@]]@]]:@!]@]]@]]]@]]@]@]]::::!@#@!#:@!#]@]:@!#@]]@]]@]:@]]@]:!@#!@:!@]@]:!@]@]]:!@]@]:!@#@]:]@]]@]@]:!]]@]]:!@]]]@]@]]@]]@]]]@]@]@]]@]:S:ADAS:D:!@:#!@:#:@!#:!@#!@]@]]@]]@]@]]@]]@]]@]@]]@]]@]]]@]@]]@]]]@]@]]:@]]@]]@]]@]@]]@]]@]@]@]]@]:!@#!@#!#AS:ASDSAD:!@#!@#:ASDASD:!@#@![root@web tmp]# tr \'\'

测试

使用小工具截取当前主机IP;截取NetMask;截取broadcast

ifconfig ens33 | grep ‘broadcast’|tr -d ‘[a-zA-Z]’

 ifconfig ens33|grep \'Bcast\'|tr -d \'[a-zA-Z]\'|cut -d: -f2,3,4

Linux730 tr:-d /-s;sort:-r,-n,-R,-o,-t,-k,-u;bash;cut:-d,-c;tee -a;uniq -c -i

[root@web tmp]# ifconfig ens33ens33: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500 inet 192.168.235.20 netmask 255.255.255.0 broadcast 192.168.235.255 inet6 fe80::20c:29ff:fe97:845e prefixlen 64 scopeid 0x20<link> ether 00:0c:29:97:84:5e txqueuelen 1000 (Ethernet) RX packets 222598 bytes 16375798 (15.6 MiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 367611 bytes 159710111 (152.3 MiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0[root@web tmp]# ifconfig ens33|grep \'Bcast\'您在 /var/spool/mail/root 中有邮件[root@web tmp]#

Linux730 tr:-d /-s;sort:-r,-n,-R,-o,-t,-k,-u;bash;cut:-d,-c;tee -a;uniq -c -i

[root@web tmp]# ifconfig ens33|grep \'Bcast\'您在 /var/spool/mail/root 中有邮件[root@web tmp]# ifconfig ens33|grep -i \'Bcast\'您在 /var/spool/mail/root 中有邮件[root@web tmp]# ifconfig ens33 |grep \'broadcast\' inet 192.168.235.20 netmask 255.255.255.0 broadcast 192.168.235.255[root@web tmp]# ifconfig ens33|grep \'broadcast\'|tr -d \'[a-z]\' 192.168.235.20 255.255.255.0 192.168.235.255

截取MAC地址

[root@web tmp]# ifconfig ens33 | grep \'ether\' |tr -s \' \' |ls1.txt file2 sys-20250717.tar.gz systemd-private-6f37c267bc534142983b62ad1ab0be9a-bolt.service-LMvltW2.txt file3.patch sys-20250718.tar.gz systemd-private-6f37c267bc534142983b62ad1ab0be9a-chronyd.service-UWJorp3.txt file5 sys-20250720.tar.gz systemd-private-6f37c267bc534142983b62ad1ab0be9a-colord.service-tLvcX35.txt file6.patch sys-20250721.tar.gz systemd-private-6f37c267bc534142983b62ad1ab0be9a-cups.service-LjtpWQ6.txt file.patch  sys-20250722.tar.gz systemd-private-6f37c267bc534142983b62ad1ab0be9a-rtkit-daemon.service-gttbXabak.boot passwd  sys-20250723.tar.gz vmware-root_1022-2999133054dir1 swapfile sys-20250724.tar.gz vmware-root_1207-3979642956dir2 sys-20250714.tar.gz sys-20250728.tar.gz vmware-root_845-4021653450EdP.aunSeOi sys-20250715.tar.gz sys-20250729.tar.gz vmware-root_971-4290232077file1 sys-20250716.tar.gz sys-20250730.tar.gz

Linux730 tr:-d /-s;sort:-r,-n,-R,-o,-t,-k,-u;bash;cut:-d,-c;tee -a;uniq -c -i
为什么 cut -d ’ ’ -f3
ether 00:0c:29:97:84:5e txqueuelen 1000 (Ethernet)
得到MAC地址 为什么是f3
Linux730 tr:-d /-s;sort:-r,-n,-R,-o,-t,-k,-u;bash;cut:-d,-c;tee -a;uniq -c -i

[root@web tmp]# ifconfig ens33 |grep \'ether\' |tr -s \' \'|cut -d \' \' -f300:0c:29:97:84:5e您在 /var/spool/mail/root 中有邮件
[root@web tmp]# ifconfig ens33|grep broadcast|tr -s \' \'|cut -d \' \' -f7192.168.235.255您在 /var/spool/mail/root 中有邮件[root@web tmp]# ifconfig ens33|grep broadcast|tr -d \'[a-zA-Z]\' 192.168.235.20 255.255.255.0 192.168.235.255您在 /var/spool/mail/root 中有邮件
[root@web tmp]# ifconfig ens33|grep broadcast|tr -d \'[a-zA-Z]\'|tr -s \' \'|cut -d \' \' -f4192.168.235.255您在 /var/spool/mail/root 中有邮件

将系统中所有普通用户的用户名、密码、shell保存在一个文件中,用户名、密码 shell间用shell连接

grep ‘bash$’ passwd|grep -v ‘root’|cut -d: -f1,2,7|tr ‘:’ ‘\\t’|tee ‘abc.txt’

[root@web tmp]# grep \'bash$\' passwdroot:x:0:0:root:/root:/bin/bashcaozx26:x:1000:1002:caozx26:/home/caozx26:/bin/bashXOAP:x:1002:1000::/rhome/XOAP:/bin/bashcao1:x:1004:1223::/home/cao1:/bin/bashcao2:x:1005:1005::/home/cao2:/bin/bashxiaocao:x:1006:1006::/home/xiaocao:/bin/bashxiao6:x:1007:1007::/home/xiao6:/bin/bashtom:x:1008:1008::/home/tom:/bin/bashjack:x:1009:1009::/home/jack:/bin/bashcw01:x:1010:1224::/home/cw01:/bin/bashsc01:x:1011:1226::/home/sc01:/bin/bashrs01:x:1012:1225::/home/rs01:/bin/bashboss01:x:1013:1004::/home/boss01:/bin/bashcw02:x:1014:1224::/home/cw02:/bin/bashsc02:x:1015:1226::/home/sc02:/bin/bashrs02:x:1016:1225::/home/rs02:/bin/bashharry:x:1017:1017::/home/mahei/redhat/harry:/bin/bashnetasha:x:1018:1018::/home/netasha:/bin/bashsarsh:x:1019:1228::/home/sarsh:/bin/bashOOO:x:1020:1020::/home/OOO:/bin/bashjerry:x:1021:1229::/home/jerry:/bin/bashkefu:x:1022:1022::/home/kefu:/bin/bashkefu2:x:1023:1023::/home/kefu2:/bin/bashuser01:x:1024:1024::/home/user01:/bin/bash您在 /var/spool/mail/root 中有邮件[root@web tmp]# grep \'bash$\' passwd|grep -v \'root\'caozx26:x:1000:1002:caozx26:/home/caozx26:/bin/bashXOAP:x:1002:1000::/rhome/XOAP:/bin/bashcao1:x:1004:1223::/home/cao1:/bin/bashcao2:x:1005:1005::/home/cao2:/bin/bashxiaocao:x:1006:1006::/home/xiaocao:/bin/bashxiao6:x:1007:1007::/home/xiao6:/bin/bashtom:x:1008:1008::/home/tom:/bin/bashjack:x:1009:1009::/home/jack:/bin/bashcw01:x:1010:1224::/home/cw01:/bin/bashsc01:x:1011:1226::/home/sc01:/bin/bashrs01:x:1012:1225::/home/rs01:/bin/bashboss01:x:1013:1004::/home/boss01:/bin/bashcw02:x:1014:1224::/home/cw02:/bin/bashsc02:x:1015:1226::/home/sc02:/bin/bashrs02:x:1016:1225::/home/rs02:/bin/bashharry:x:1017:1017::/home/mahei/redhat/harry:/bin/bashnetasha:x:1018:1018::/home/netasha:/bin/bashsarsh:x:1019:1228::/home/sarsh:/bin/bashOOO:x:1020:1020::/home/OOO:/bin/bashjerry:x:1021:1229::/home/jerry:/bin/bashkefu:x:1022:1022::/home/kefu:/bin/bashkefu2:x:1023:1023::/home/kefu2:/bin/bashuser01:x:1024:1024::/home/user01:/bin/bash[root@web tmp]# grep \'bash$\' passwd|grep -v \'root\'|cut -d: -f1,2,7caozx26:x:/bin/bashXOAP:x:/bin/bashcao1:x:/bin/bashcao2:x:/bin/bashxiaocao:x:/bin/bashxiao6:x:/bin/bashtom:x:/bin/bashjack:x:/bin/bashcw01:x:/bin/bashsc01:x:/bin/bashrs01:x:/bin/bashboss01:x:/bin/bashcw02:x:/bin/bashsc02:x:/bin/bashrs02:x:/bin/bashharry:x:/bin/bashnetasha:x:/bin/bashsarsh:x:/bin/bashOOO:x:/bin/bashjerry:x:/bin/bashkefu:x:/bin/bashkefu2:x:/bin/bashuser01:x:/bin/bash您在 /var/spool/mail/root 中有邮件[root@web tmp]# grep \'bash$\' passwd|grep -v \'root\'|cut -d: -f1,2,7|tr \':\' \'\\t\'caozx26 x /bin/bashXOAP x /bin/bashcao1 x /bin/bashcao2 x /bin/bashxiaocao x /bin/bashxiao6 x /bin/bashtom x /bin/bashjack x /bin/bashcw01 x /bin/bashsc01 x /bin/bashrs01 x /bin/bashboss01 x /bin/bashcw02 x /bin/bashsc02 x /bin/bashrs02 x /bin/bashharry x /bin/bashnetasha x /bin/bashsarsh x /bin/bashOOO x /bin/bashjerry x /bin/bashkefu x /bin/bashkefu2 x /bin/bashuser01 x /bin/bash您在 /var/spool/mail/root 中有邮件[root@web tmp]# grep \'bash$\' passwd|grep -v \'root\'|cut -d: -f1,2,7|tr \':\' \'\\t\'|tee abc.txtcaozx26 x /bin/bashXOAP x /bin/bashcao1 x /bin/bashcao2 x /bin/bashxiaocao x /bin/bashxiao6 x /bin/bashtom x /bin/bashjack x /bin/bashcw01 x /bin/bashsc01 x /bin/bashrs01 x /bin/bashboss01 x /bin/bashcw02 x /bin/bashsc02 x /bin/bashrs02 x /bin/bashharry x /bin/bashnetasha x /bin/bashsarsh x /bin/bashOOO x /bin/bashjerry x /bin/bashkefu x /bin/bashkefu2 x /bin/bashuser01 x /bin/bash您在 /var/spool/mail/root 中有邮件[root@web tmp]# cat abc.txtcaozx26 x /bin/bashXOAP x /bin/bashcao1 x /bin/bashcao2 x /bin/bashxiaocao x /bin/bashxiao6 x /bin/bashtom x /bin/bashjack x /bin/bashcw01 x /bin/bashsc01 x /bin/bashrs01 x /bin/bashboss01 x /bin/bashcw02 x /bin/bashsc02 x /bin/bashrs02 x /bin/bashharry x /bin/bashnetasha x /bin/bashsarsh x /bin/bashOOO x /bin/bashjerry x /bin/bashkefu x /bin/bashkefu2 x /bin/bashuser01 x /bin/bash您在 /var/spool/mail/root 中有邮件

bash

常见快捷键

ctrl+r 搜索历史命令
ctrl+u 清除光标前字符
ctrl+k 清楚光标后字符
ctrl+a 移动命令最前方
ctrl+e 移动到命令最后端

常用通配符

*匹配0或多个任意字符
?匹配任意单个字符
[list] 匹配[list]中的任意单个字符,或一组单个字符
[!list] 匹配除list的字符
[string1,string2,…] 匹配string1 string2 或更多字符串

bash中的引号

\" “:将”\"中的内容当成整体来看,允许通过 $ 符号引用其他变量值
’ ’ :将’ \'中的内容当成整体来看,禁止引用其他变量值,特殊符号视为普通字符
`` : 命令优先执行,和$()一样。如果存在嵌套,不能用

“” ‘’

echo \"(hostname)\"echo′(hostname)\"echo \'(hostname)\"echo(hostname)’
echo hostname

[root@web tmp]# echo \"$(hostname)\"web.cn您在 /var/spool/mail/root 中有邮件[root@web tmp]# echo \'hostname\'hostname[root@web tmp]# echo \"hostname\"hostname[root@web tmp]# echo \'$(hostname)\'$(hostname)[root@web tmp]# echo \"$(hostname)\"web.cn[root@web tmp]# echo \"$(date)\"2025年 07月 30日 星期三 23:27:30 CST您在 /var/spool/mail/root 中有邮件[root@web tmp]# echo \'$(date)\'$(date)[root@web tmp]# echo $(date)2025年 07月 30日 星期三 23:27:56 CST[root@web tmp]# echo $(hostname)web.cn[root@web tmp]# echo $(date +%F)2025-07-30您在 /var/spool/mail/root 中有邮件[root@web tmp]# echo `echo $(date +%F)`2025-07-30您在 /var/spool/mail/root 中有邮件[root@web tmp]# echo `echo $(hostname)`web.cn[root@web tmp]# echo `hostname`web.cn[root@web tmp]# echo `date+%F`bash: date+%F: 未找到命令...[root@web tmp]# echo `date +%F`2025-07-30您在 /var/spool/mail/root 中有邮件[root@web tmp]# echo `echo `hostname``hostname[root@web tmp]# echo `echo $(hostname)`web.cn[root@web tmp]#

记录

root@192.168.235.20\'s password: ┌────────────────────────────────────────────────────────────────────┐ │ • MobaXterm 20.0 • │ │ (SSH client, X-server and networking tools) │ │ │ │ ➤ SSH session to root@192.168.235.20 │ │ • SSH compression : ✘│ │ • SSH-browser : ✔│ │ • X11-forwarding : ✔ (remote display is forwarded through SSH) │ │ • DISPLAY : ✔ (automatically set on remote server) │ │ │ │ ➤ For more info, ctrl+click on help or visit our website  │ └────────────────────────────────────────────────────────────────────┘Last login: Tue Jul 29 19:19:36 2025 from 192.168.235.1[root@web ~]# uniq 1.txtuniq: 1.txt: 没有那个文件或目录您在 /var/spool/mail/root 中有新邮件[root@web ~]# cd /tmp[root@web tmp]# uniq 1.txt112:2223:33321312:3:2:1:312:3123123123213123:1232112:123:!@#:!@#:@!:!@#!@:#:!@#:!@:#!@:21312312:S:ADAS:D:!@:#!@:#:@!#:!@#!@12312312123122121312312:!@#!@#!#AS:ASDSAD:!@#!@#:ASDASD:!@#@!213123::::!@#@!#:@!#213:@!#12123123:!@#213:!@#123:!@#!@#:!#!@#:123123:@!3123213213:12312:!@#!@:!@312:!@3123:!@312:!@#12:21321312:!23123:!@3123213232131232132312312312312312312312312321312312321312312312123123[root@web tmp]# uniq -c 1.txt 1 112:2223:333213 1 12:3:2:1:312:3123 1 123123213123:123 1 2112:123:!@#:!@#:@!:!@#!@:#:!@#:!@:#!@: 1 21312312:S:ADAS:D:!@:#!@:#:@!#:!@#!@ 1 12312312123122121312312:!@#!@#!#AS:ASDSAD:!@#!@#:ASDASD:!@#@! 1 213123::::!@#@!#:@!#213:@!#12 1 123123:!@#213:!@#123:!@#!@#:!#!@#:123123:@!3123 1 213213:12312:!@#!@:!@312:!@3123:!@312:!@#12:21321312:!23123:!@3 1 123213 1 2 1 3213123 1 21 1 32 1 312 1 3 1 12312312312 1 3 1 123123123213 1 1 12312321 1 312312312 1 123123[root@web tmp]# uniq -i 1.txt112:2223:33321312:3:2:1:312:3123123123213123:1232112:123:!@#:!@#:@!:!@#!@:#:!@#:!@:#!@:21312312:S:ADAS:D:!@:#!@:#:@!#:!@#!@12312312123122121312312:!@#!@#!#AS:ASDSAD:!@#!@#:ASDASD:!@#@!213123::::!@#@!#:@!#213:@!#12123123:!@#213:!@#123:!@#!@#:!#!@#:123123:@!3123213213:12312:!@#!@:!@312:!@3123:!@312:!@#12:21321312:!23123:!@3123213232131232132312312312312312312312312321312312321312312312123123[root@web tmp]# echo hello world | tee file5hello world您在 /var/spool/mail/root 中有邮件[root@web tmp]# cat file5hello world[root@web tmp]# diff file1 file2您在 /var/spool/mail/root 中有邮件[root@web tmp]# diff file2 file3diff: file3: 没有那个文件或目录[root@web tmp]# diff text1 text2diff: text1: 没有那个文件或目录diff: text2: 没有那个文件或目录[root@web tmp]# ls1.txt file3.patch sys-20250718.tar.gz systemd-private-6f37c267bc534142983b62ad1ab0be9a-bolt.service-LMvltW2.txt file5 sys-20250720.tar.gz systemd-private-6f37c267bc534142983b62ad1ab0be9a-chronyd.service-UWJorp3.txt file.patch  sys-20250721.tar.gz systemd-private-6f37c267bc534142983b62ad1ab0be9a-colord.service-tLvcX3bak.boot passwd  sys-20250722.tar.gz systemd-private-6f37c267bc534142983b62ad1ab0be9a-cups.service-LjtpWQdir1 swapfile sys-20250723.tar.gz systemd-private-6f37c267bc534142983b62ad1ab0be9a-rtkit-daemon.service-gttbXadir2 sys-20250714.tar.gz sys-20250724.tar.gz vmware-root_1022-2999133054EdP.aunSeOi sys-20250715.tar.gz sys-20250728.tar.gz vmware-root_1207-3979642956file1 sys-20250716.tar.gz sys-20250729.tar.gz vmware-root_845-4021653450file2 sys-20250717.tar.gz sys-20250730.tar.gz vmware-root_971-4290232077[root@web tmp]# diff 1.txt 2.txt1c1,4> 2> 3> 33c6,9 21> 32> 112:2223:333213> 3125,7c11< 21312312:S:ADAS:D:!@:#!@:#:@!#:!@#!@< 12312312123122121312312:!@#!@#!#AS:ASDSAD:!@#!@#:ASDASD:!@#@! 1231239d12< 213213:12312:!@#!@:!@312:!@3123:!@312:!@#12:21321312:!23123:!@311c14,15 213123::::!@#@!#:@!#213:@!#12> 213213:12312:!@#!@:!@312:!@3123:!@312:!@#12:21321312:!23123:!@313,20d16< 21< 32< 312< 3< 12312312312< 3< 123123123213 21312312:S:ADAS:D:!@:#!@:#:@!#:!@#!@23c20,23 12312312312> 123123123213> 123123213123:123> 12312312123122121312312:!@#!@#!#AS:ASDSAD:!@#!@#:ASDASD:!@#@![root@web tmp]# diff 2.txt 3.txt1,23c1,27<< 2< 3< 3< 12:3:2:1:312:3123< 21< 32< 112:2223:333213< 312< 2112:123:!@#:!@#:@!:!@#!@:#:!@#:!@:#!@:< 123123< 123123:!@#213:!@#123:!@#!@#:!#!@#:123123:@!3123< 123213< 213123::::!@#@!#:@!#213:@!#12< 213213:12312:!@#!@:!@312:!@3123:!@312:!@#12:21321312:!23123:!@3< 3213123< 12312321< 21312312:S:ADAS:D:!@:#!@:#:@!#:!@#!@< 312312312< 12312312312< 123123123213< 123123213123:123 root:x:0:0:root:/root:/bin/bash> bin:x:1:1:bin:/bin:/sbin/nologin> daemon:x:2:2:daemon:/sbin:/sbin/nologin> adm:x:3:4:adm:/var/adm:/sbin/nologin> lp:x:4:7:lp:/var/spool/lpd:/sbin/nologin> sync:x:5:0:sync:/sbin:/bin/sync> shutdown:x:6:0:shutdown:/sbin:/sbin/shutdown> halt:x:7:0:halt:/sbin:/sbin/halt> mail:x:8:12:mail:/var/spool/mail:/sbin/nologin> operator:x:11:0:operator:/root:/sbin/nologin> games:x:12:100:games:/usr/games:/sbin/nologin> ftp:x:14:50:FTP User:/var/ftp:/sbin/nologin> nobody:x:99:99:Nobody:/:/sbin/nologin> systemd-network:x:192:192:systemd Network Management:/:/sbin/nologin> dbus:x:81:81:System message bus:/:/sbin/nologin> polkitd:x:999:998:User for polkitd:/:/sbin/nologin> libstoragemgmt:x:998:995:daemon account for libstoragemgmt:/var/run/lsm:/sbin/nologin> colord:x:997:994:User for colord:/var/lib/colord:/sbin/nologin> rpc:x:32:32:Rpcbind Daemon:/var/lib/rpcbind:/sbin/nologin> saned:x:996:993:SANE scanner daemon user:/usr/share/sane:/sbin/nologin> gluster:x:995:992:GlusterFS daemons:/run/gluster:/sbin/nologin> aaaaaaaaaaaaaaaaaaaaaa> bbbbbbbbbbbbbbbbbbbbbbb1111111111222222222333333331cccccccccc> hello world 888> 666> 777> 999[root@web tmp]# diff file1 file2[root@web tmp]# diff -c 1.txt 2.txt*** 1.txt 2025-07-28 21:46:59.593951441 +0800--- 2.txt 2025-07-28 21:12:17.477645718 +0800****************** 1,23 ****! 112:2223:333213 12:3:2:1:312:3123! 123123213123:123 2112:123:!@#:!@#:@!:!@#!@:#:!@#:!@:#!@:! 21312312:S:ADAS:D:!@:#!@:#:@!#:!@#!@! 12312312123122121312312:!@#!@#!#AS:ASDSAD:!@#!@#:ASDASD:!@#@!! 213123::::!@#@!#:@!#213:@!#12 123123:!@#213:!@#123:!@#!@#:!#!@#:123123:@!3123- 213213:12312:!@#!@:!@312:!@3123:!@312:!@#12:21321312:!23123:!@3 123213! 2 3213123- 21- 32- 312- 3- 12312312312- 3- 123123123213- 12312321 312312312! 123123--- 1,23 ----!! 2! 3! 3 12:3:2:1:312:3123! 21! 32! 112:2223:333213! 312 2112:123:!@#:!@#:@!:!@#!@:#:!@#:!@:#!@:! 123123 123123:!@#213:!@#123:!@#!@#:!#!@#:123123:@!3123 123213! 213123::::!@#@!#:@!#213:@!#12! 213213:12312:!@#!@:!@312:!@3123:!@312:!@#12:21321312:!23123:!@3 3213123 12312321+ 21312312:S:ADAS:D:!@:#!@:#:@!#:!@#!@ 312312312! 12312312312! 123123123213! 123123213123:123! 12312312123122121312312:!@#!@#!#AS:ASDSAD:!@#!@#:ASDASD:!@#@!您在 /var/spool/mail/root 中有邮件[root@web tmp]# diff dir1 dir2只在 dir1 存在:file1只在 dir2 存在:file2您在 /var/spool/mail/root 中有邮件[root@web tmp]# copy 1.txt 5.txtbash: copy: 未找到命令...您在 /var/spool/mail/root 中有邮件[root@web tmp]# cp 1.txt 5.txt[root@web tmp]# cp 2.txt 6.txt[root@web tmp]# diff -uN 5.txt 6.txt--- 5.txt 2025-07-30 20:05:17.378243112 +0800+++ 6.txt 2025-07-30 20:05:24.485368451 +0800@@ -1,23 +1,23 @@-112:2223:333213++2+3+3 12:3:2:1:312:3123-123123213123:123+21+32+112:2223:333213+312 2112:123:!@#:!@#:@!:!@#!@:#:!@#:!@:#!@:-21312312:S:ADAS:D:!@:#!@:#:@!#:!@#!@-12312312123122121312312:!@#!@#!#AS:ASDSAD:!@#!@#:ASDASD:!@#@!-213123::::!@#@!#:@!#213:@!#12+123123 123123:!@#213:!@#123:!@#!@#:!#!@#:123123:@!3123-213213:12312:!@#!@:!@312:!@3123:!@312:!@#12:21321312:!23123:!@3 123213-2+213123::::!@#@!#:@!#213:@!#12+213213:12312:!@#!@:!@312:!@3123:!@312:!@#12:21321312:!23123:!@3 3213123-21-32-312-3-12312312312-3-123123123213- 12312321+21312312:S:ADAS:D:!@:#!@:#:@!#:!@#!@ 312312312-123123+12312312312+123123123213+123123213123:123+12312312123122121312312:!@#!@#!#AS:ASDSAD:!@#!@#:ASDASD:!@#@![root@web tmp]# diff -uN 5.txt 6.txt >file6.patch您在 /var/spool/mail/root 中有邮件[root@web tmp]# patch 5.txt file6.patchpatching file 5.txt您在 /var/spool/mail/root 中有邮件[root@web tmp]# diff 5.txt 6.txt[root@web tmp]# diff -c 5.txt 6.txt[root@web tmp]# diff -u 5.txt 6.txt您在 /var/spool/mail/root 中有邮件[root@web tmp]# cat 5.txt23312:3:2:1:312:31232132112:2223:3332133122112:123:!@#:!@#:@!:!@#!@:#:!@#:!@:#!@:123123123123:!@#213:!@#123:!@#!@#:!#!@#:123123:@!3123123213213123::::!@#@!#:@!#213:@!#12213213:12312:!@#!@:!@312:!@3123:!@312:!@#12:21321312:!23123:!@332131231231232121312312:S:ADAS:D:!@:#!@:#:@!#:!@#!@31231231212312312312123123123213123123213123:12312312312123122121312312:!@#!@#!#AS:ASDSAD:!@#!@#:ASDASD:!@#@![root@web tmp]# cat 6.txt23312:3:2:1:312:31232132112:2223:3332133122112:123:!@#:!@#:@!:!@#!@:#:!@#:!@:#!@:123123123123:!@#213:!@#123:!@#!@#:!#!@#:123123:@!3123123213213123::::!@#@!#:@!#213:@!#12213213:12312:!@#!@:!@312:!@3123:!@312:!@#12:21321312:!23123:!@332131231231232121312312:S:ADAS:D:!@:#!@:#:@!#:!@#!@31231231212312312312123123123213123123213123:12312312312123122121312312:!@#!@#!#AS:ASDSAD:!@#!@#:ASDASD:!@#@![root@web tmp]# cat 5.txt | tr -d \'[:/]\'233123213123123213211222233332133122112123!@#!@#@!!@#!@#!@#!@#!@123123123123!@#213!@#123!@#!@#!#!@#123123@!3123123213213123!@#@!#@!#213@!#1221321312312!@#!@!@312!@3123!@312!@#1221321312!23123!@332131231231232121312312SADASD!@#!@#@!#!@#!@3123123121231231231212312312321312312321312312312312312123122121312312!@#!@#!#ASASDSAD!@#!@#ASDASD!@#@!您在 /var/spool/mail/root 中有邮件[root@web tmp]# tr -s [1-9] < 1.txt12:23:321312:3:2:1:312:3123123123213123:123212:123:!@#:!@#:@!:!@#!@:#:!@#:!@:#!@:21312312:S:ADAS:D:!@:#!@:#:@!#:!@#!@1231231212312121312312:!@#!@#!#AS:ASDSAD:!@#!@#:ASDASD:!@#@!213123::::!@#@!#:@!#213:@!#12123123:!@#213:!@#123:!@#!@#:!#!@#:123123:@!3123213213:12312:!@#!@:!@312:!@3123:!@312:!@#12:21321312:!23123:!@3123213232131232132312312312312312312312312321312312321312312312123123[root@web tmp]# tr -s [1-9] <5.txt23312:3:2:1:312:3123213212:23:3213312212:123:!@#:!@#:@!:!@#!@:#:!@#:!@:#!@:123123123123:!@#213:!@#123:!@#!@#:!#!@#:123123:@!3123123213213123::::!@#@!#:@!#213:@!#12213213:12312:!@#!@:!@312:!@3123:!@312:!@#12:21321312:!23123:!@332131231231232121312312:S:ADAS:D:!@:#!@:#:@!#:!@#!@31231231212312312312123123123213123123213123:1231231231212312121312312:!@#!@#!#AS:ASDSAD:!@#!@#:ASDASD:!@#@!您在 /var/spool/mail/root 中有邮件[root@web tmp]# tr \'[1-9]\' \'[@]\' < 5.txt]]]@]:]:]:@:]@]:]@]]]@]]@@]:]]]]:]]]]@]]@]]@@]:@]]:!@#:!@#:@!:!@#!@:#:!@#:!@:#!@:@]]@]]@]]@]]:!@#]@]:!@#@]]:!@#!@#:!#!@#:@]]@]]:@!]@]]@]]]@]]@]@]]::::!@#@!#:@!#]@]:@!#@]]@]]@]:@]]@]:!@#!@:!@]@]:!@]@]]:!@]@]:!@#@]:]@]]@]@]:!]]@]]:!@]]]@]@]]@]]@]]]@]@]@]]@]:S:ADAS:D:!@:#!@:#:@!#:!@#!@]@]]@]]@]@]]@]]@]]@]@]]@]]@]]]@]@]]@]]]@]@]]:@]]@]]@]]@]@]]@]]@]@]@]]@]:!@#!@#!#AS:ASDSAD:!@#!@#:ASDASD:!@#@![root@web tmp]# ifconfigens33: flags=4163 mtu 1500 inet 192.168.235.20 netmask 255.255.255.0 broadcast 192.168.235.255 inet6 fe80::20c:29ff:fe97:845e prefixlen 64 scopeid 0x20 ether 00:0c:29:97:84:5e txqueuelen 1000 (Ethernet) RX packets 221160 bytes 16267740 (15.5 MiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 365321 bytes 158737689 (151.3 MiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0lo: flags=73 mtu 65536 inet 127.0.0.1 netmask 255.0.0.0 inet6 ::1 prefixlen 128 scopeid 0x10 loop txqueuelen 1000 (Local Loopback) RX packets 64 bytes 5280 (5.1 KiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 64 bytes 5280 (5.1 KiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0virbr0: flags=4099 mtu 1500 inet 192.168.122.1 netmask 255.255.255.0 broadcast 192.168.122.255 ether 52:54:00:2a:35:da txqueuelen 1000 (Ethernet) RX packets 0 bytes 0 (0.0 B) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 0 bytes 0 (0.0 B) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0您在 /var/spool/mail/root 中有邮件[root@web tmp]# inconfig ens33bash: inconfig: 未找到命令...[root@web tmp]# ifconfig ens33ens33: flags=4163 mtu 1500 inet 192.168.235.20 netmask 255.255.255.0 broadcast 192.168.235.255 inet6 fe80::20c:29ff:fe97:845e prefixlen 64 scopeid 0x20 ether 00:0c:29:97:84:5e txqueuelen 1000 (Ethernet) RX packets 221300 bytes 16278766 (15.5 MiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 365485 bytes 158799857 (151.4 MiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0[root@web tmp]# ifconfig ens33|grep \'Bcast\'|tr -d \'[a-zA-Z]\'|cut -d: -f2,3,4您在 /var/spool/mail/root 中有邮件[root@web tmp]# ifconfig ens33ens33: flags=4163 mtu 1500 inet 192.168.235.20 netmask 255.255.255.0 broadcast 192.168.235.255 inet6 fe80::20c:29ff:fe97:845e prefixlen 64 scopeid 0x20 ether 00:0c:29:97:84:5e txqueuelen 1000 (Ethernet) RX packets 222598 bytes 16375798 (15.6 MiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 367611 bytes 159710111 (152.3 MiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0[root@web tmp]# ifconfig ens33|grep \'Bcast\'您在 /var/spool/mail/root 中有邮件[root@web tmp]# ifconfig ens33|grep -i \'Bcast\'您在 /var/spool/mail/root 中有邮件[root@web tmp]# ifconfig ens33 |grep \'broadcast\' inet 192.168.235.20 netmask 255.255.255.0 broadcast 192.168.235.255[root@web tmp]# ifconfig ens33|grep \'broadcast\'|tr -d \'[a-z]\' 192.168.235.20 255.255.255.0 192.168.235.255您在 /var/spool/mail/root 中有邮件[root@web tmp]# ifconfig ens33|grep \'broadcast\'|tr -d \'[a-z]\'|cut -d: -f2,3,4 192.168.235.20 255.255.255.0 192.168.235.255您在 /var/spool/mail/root 中有邮件[root@web tmp]# ifconfig ens33|grep \'HWaddr\'您在 /var/spool/mail/root 中有邮件[root@web tmp]# ifconfig ens33 |grep \'ether\' ether 00:0c:29:97:84:5e txqueuelen 1000 (Ethernet)您在 /var/spool/mail/root 中有邮件[root@web tmp]# ifconfig ens33|grep \'ether\'|tr -s \'\' ether 00:0c:29:97:84:5e txqueuelen 1000 (Ethernet)您在 /var/spool/mail/root 中有邮件[root@web tmp]# ifconfig ens33 |grep \'ethre\'|cut -d\' \' f2cut: 您必须指定一组字节、字符或域的列表Try \'cut --help\' for more information.您在 /var/spool/mail/root 中有邮件[root@web tmp]# ifconfig ens33 |grep \'ether\'|cut -d\' \' -f2您在 /var/spool/mail/root 中有邮件[root@web tmp]# ifconfig ens33 |grep \'ether\' ether 00:0c:29:97:84:5e txqueuelen 1000 (Ethernet)[root@web tmp]# ifconfig ens33|grep \'ether|tr -s \' \'> ^C您在 /var/spool/mail/root 中有邮件[root@web tmp]# ifconfig ens33|grep \'ether\'|tr -s \'\'|cut -d\' \' -f2您在 /var/spool/mail/root 中有邮件[root@web tmp]# ifconfig ens33 | grep \'ether\' |tr -s \' \' | cut -d \' \' -f300:0c:29:97:84:5e您在 /var/spool/mail/root 中有邮件[root@web tmp]# ifconfig ens33 | grep \'ether\' |tr -s \' \' |ls1.txt file2 sys-20250717.tar.gz systemd-private-6f37c267bc534142983b62ad1ab0be9a-bolt.service-LMvltW2.txt file3.patch sys-20250718.tar.gz systemd-private-6f37c267bc534142983b62ad1ab0be9a-chronyd.service-UWJorp3.txt file5 sys-20250720.tar.gz systemd-private-6f37c267bc534142983b62ad1ab0be9a-colord.service-tLvcX35.txt file6.patch sys-20250721.tar.gz systemd-private-6f37c267bc534142983b62ad1ab0be9a-cups.service-LjtpWQ6.txt file.patch  sys-20250722.tar.gz systemd-private-6f37c267bc534142983b62ad1ab0be9a-rtkit-daemon.service-gttbXabak.boot passwd  sys-20250723.tar.gz vmware-root_1022-2999133054dir1 swapfile sys-20250724.tar.gz vmware-root_1207-3979642956dir2 sys-20250714.tar.gz sys-20250728.tar.gz vmware-root_845-4021653450EdP.aunSeOi sys-20250715.tar.gz sys-20250729.tar.gz vmware-root_971-4290232077file1 sys-20250716.tar.gz sys-20250730.tar.gz您在 /var/spool/mail/root 中有邮件[root@web tmp]# ifconfig ens33 |grep \'ether\' |tr -s \' \'|cat ether 00:0c:29:97:84:5e txqueuelen 1000 (Ethernet)您在 /var/spool/mail/root 中有邮件[root@web tmp]# ifconfig ens33 |grep \'ether\' |tr -s \' \'|cut -d \' \' -f300:0c:29:97:84:5e您在 /var/spool/mail/root 中有邮件[root@web tmp]# ifconfig ens33|grep brodecast您在 /var/spool/mail/root 中有邮件[root@web tmp]# brodacastbash: brodacast: 未找到命令...[root@web tmp]# ifconfig ens33ens33: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500 inet 192.168.235.20 netmask 255.255.255.0 broadcast 192.168.235.255 inet6 fe80::20c:29ff:fe97:845e prefixlen 64 scopeid 0x20<link> ether 00:0c:29:97:84:5e txqueuelen 1000 (Ethernet) RX packets 240830 bytes 17728559 (16.9 MiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 398223 bytes 172882425 (164.8 MiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0[root@web tmp]# ifconfig ens33|grep broadcast inet 192.168.235.20 netmask 255.255.255.0 broadcast 192.168.235.255您在 /var/spool/mail/root 中有邮件[root@web tmp]# ifconfig ens33|grep broadcast|tr -s \' \' inet 192.168.235.20 netmask 255.255.255.0 broadcast 192.168.235.255[root@web tmp]# ifconfig ens33|grep broadcast| tr -s \'\'|cut -d \' \' -f7您在 /var/spool/mail/root 中有邮件[root@web tmp]# ifconfig ens33|grep broadcast|tr -s \' \'|cut -d \' \' -f7192.168.235.255您在 /var/spool/mail/root 中有邮件[root@web tmp]# ifconfig ens33|grep broadcast|tr -d \'[a-zA-Z]\' 192.168.235.20 255.255.255.0 192.168.235.255您在 /var/spool/mail/root 中有邮件[root@web tmp]# ifconfig ens33|grep broadcast|tr -d \'[a-zA-Z]\'|tr -s \' \'|cut -d \' \' -f4192.168.235.255您在 /var/spool/mail/root 中有邮件[root@web tmp]# grep \'bash$\' passwdroot:x:0:0:root:/root:/bin/bashcaozx26:x:1000:1002:caozx26:/home/caozx26:/bin/bashXOAP:x:1002:1000::/rhome/XOAP:/bin/bashcao1:x:1004:1223::/home/cao1:/bin/bashcao2:x:1005:1005::/home/cao2:/bin/bashxiaocao:x:1006:1006::/home/xiaocao:/bin/bashxiao6:x:1007:1007::/home/xiao6:/bin/bashtom:x:1008:1008::/home/tom:/bin/bashjack:x:1009:1009::/home/jack:/bin/bashcw01:x:1010:1224::/home/cw01:/bin/bashsc01:x:1011:1226::/home/sc01:/bin/bashrs01:x:1012:1225::/home/rs01:/bin/bashboss01:x:1013:1004::/home/boss01:/bin/bashcw02:x:1014:1224::/home/cw02:/bin/bashsc02:x:1015:1226::/home/sc02:/bin/bashrs02:x:1016:1225::/home/rs02:/bin/bashharry:x:1017:1017::/home/mahei/redhat/harry:/bin/bashnetasha:x:1018:1018::/home/netasha:/bin/bashsarsh:x:1019:1228::/home/sarsh:/bin/bashOOO:x:1020:1020::/home/OOO:/bin/bashjerry:x:1021:1229::/home/jerry:/bin/bashkefu:x:1022:1022::/home/kefu:/bin/bashkefu2:x:1023:1023::/home/kefu2:/bin/bashuser01:x:1024:1024::/home/user01:/bin/bash您在 /var/spool/mail/root 中有邮件[root@web tmp]# grep \'bash$\' passwd|grep -v \'root\'caozx26:x:1000:1002:caozx26:/home/caozx26:/bin/bashXOAP:x:1002:1000::/rhome/XOAP:/bin/bashcao1:x:1004:1223::/home/cao1:/bin/bashcao2:x:1005:1005::/home/cao2:/bin/bashxiaocao:x:1006:1006::/home/xiaocao:/bin/bashxiao6:x:1007:1007::/home/xiao6:/bin/bashtom:x:1008:1008::/home/tom:/bin/bashjack:x:1009:1009::/home/jack:/bin/bashcw01:x:1010:1224::/home/cw01:/bin/bashsc01:x:1011:1226::/home/sc01:/bin/bashrs01:x:1012:1225::/home/rs01:/bin/bashboss01:x:1013:1004::/home/boss01:/bin/bashcw02:x:1014:1224::/home/cw02:/bin/bashsc02:x:1015:1226::/home/sc02:/bin/bashrs02:x:1016:1225::/home/rs02:/bin/bashharry:x:1017:1017::/home/mahei/redhat/harry:/bin/bashnetasha:x:1018:1018::/home/netasha:/bin/bashsarsh:x:1019:1228::/home/sarsh:/bin/bashOOO:x:1020:1020::/home/OOO:/bin/bashjerry:x:1021:1229::/home/jerry:/bin/bashkefu:x:1022:1022::/home/kefu:/bin/bashkefu2:x:1023:1023::/home/kefu2:/bin/bashuser01:x:1024:1024::/home/user01:/bin/bash[root@web tmp]# grep \'bash$\' passwd|grep -v \'root\'|cut -d: -f1,2,7caozx26:x:/bin/bashXOAP:x:/bin/bashcao1:x:/bin/bashcao2:x:/bin/bashxiaocao:x:/bin/bashxiao6:x:/bin/bashtom:x:/bin/bashjack:x:/bin/bashcw01:x:/bin/bashsc01:x:/bin/bashrs01:x:/bin/bashboss01:x:/bin/bashcw02:x:/bin/bashsc02:x:/bin/bashrs02:x:/bin/bashharry:x:/bin/bashnetasha:x:/bin/bashsarsh:x:/bin/bashOOO:x:/bin/bashjerry:x:/bin/bashkefu:x:/bin/bashkefu2:x:/bin/bashuser01:x:/bin/bash您在 /var/spool/mail/root 中有邮件[root@web tmp]# grep \'bash$\' passwd|grep -v \'root\'|cut -d: -f1,2,7|tr \':\' \'\\t\'caozx26 x /bin/bashXOAP x /bin/bashcao1 x /bin/bashcao2 x /bin/bashxiaocao x /bin/bashxiao6 x /bin/bashtom x /bin/bashjack x /bin/bashcw01 x /bin/bashsc01 x /bin/bashrs01 x /bin/bashboss01 x /bin/bashcw02 x /bin/bashsc02 x /bin/bashrs02 x /bin/bashharry x /bin/bashnetasha x /bin/bashsarsh x /bin/bashOOO x /bin/bashjerry x /bin/bashkefu x /bin/bashkefu2 x /bin/bashuser01 x /bin/bash您在 /var/spool/mail/root 中有邮件[root@web tmp]# grep \'bash$\' passwd|grep -v \'root\'|cut -d: -f1,2,7|tr \':\' \'\\t\'|tee abc.txtcaozx26 x /bin/bashXOAP x /bin/bashcao1 x /bin/bashcao2 x /bin/bashxiaocao x /bin/bashxiao6 x /bin/bashtom x /bin/bashjack x /bin/bashcw01 x /bin/bashsc01 x /bin/bashrs01 x /bin/bashboss01 x /bin/bashcw02 x /bin/bashsc02 x /bin/bashrs02 x /bin/bashharry x /bin/bashnetasha x /bin/bashsarsh x /bin/bashOOO x /bin/bashjerry x /bin/bashkefu x /bin/bashkefu2 x /bin/bashuser01 x /bin/bash您在 /var/spool/mail/root 中有邮件[root@web tmp]# cat abc.txtcaozx26 x /bin/bashXOAP x /bin/bashcao1 x /bin/bashcao2 x /bin/bashxiaocao x /bin/bashxiao6 x /bin/bashtom x /bin/bashjack x /bin/bashcw01 x /bin/bashsc01 x /bin/bashrs01 x /bin/bashboss01 x /bin/bashcw02 x /bin/bashsc02 x /bin/bashrs02 x /bin/bashharry x /bin/bashnetasha x /bin/bashsarsh x /bin/bashOOO x /bin/bashjerry x /bin/bashkefu x /bin/bashkefu2 x /bin/bashuser01 x /bin/bash您在 /var/spool/mail/root 中有邮件[root@web tmp]# cp *.conf /dir1cp: 无法获取\"*.conf\" 的文件状态(stat): 没有那个文件或目录您在 /var/spool/mail/root 中有邮件[root@web tmp]# find ./ -name !1.txt-bash: !1: event not found[root@web tmp]# echo \"$(hostname)\"web.cn您在 /var/spool/mail/root 中有邮件[root@web tmp]# echo \'hostname\'hostname[root@web tmp]# echo \"hostname\"hostname[root@web tmp]# echo \'$(hostname)\'$(hostname)[root@web tmp]# echo \"$(hostname)\"web.cn[root@web tmp]# echo \"$(date)\"2025年 07月 30日 星期三 23:27:30 CST您在 /var/spool/mail/root 中有邮件[root@web tmp]# echo \'$(date)\'$(date)[root@web tmp]# echo $(date)2025年 07月 30日 星期三 23:27:56 CST[root@web tmp]# echo $(hostname)web.cn[root@web tmp]# echo $(date +%F)2025-07-30您在 /var/spool/mail/root 中有邮件[root@web tmp]# echo `echo $(date +%F)`2025-07-30您在 /var/spool/mail/root 中有邮件[root@web tmp]# echo `echo $(hostname)`web.cn[root@web tmp]# echo `hostname`web.cn[root@web tmp]# echo `date+%F`bash: date+%F: 未找到命令...[root@web tmp]# echo `date +%F`2025-07-30您在 /var/spool/mail/root 中有邮件[root@web tmp]# echo `echo `hostname``hostname[root@web tmp]# echo `echo $(hostname)`web.cn[root@web tmp]#