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

回顾

sort

sort [选项] 文件

-u:唯一,去除重复

-r:按数字大小,倒序排序,大到小

-o:输出文件

-n:按数字大小,顺序排序,小到大

-t: -t后加分割符,按分割符为标准,进行筛选

-k:k后加数字,第k列

-R:随机排序

-b:

uniq

uniq [选项] 文件
去除连续的重复行

-i:忽略大小写
-c:统计重复行次数

bash 复制代码
[root@web ~]# uniq 1.txt
uniq: 1.txt: 没有那个文件或目录
您在 /var/spool/mail/root 中有新邮件
[root@web ~]# cd /tmp
[root@web tmp]# uniq 1.txt
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
[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.txt
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

tee

双重覆盖重定向

命令 | tee 文件

-a:双重追加重定向

cat 1.txt |tee 4.txt

echo hello world | tee file5

bash 复制代码
[root@web tmp]# echo hello world | tee file5
hello world
您在 /var/spool/mail/root 中有邮件
[root@web tmp]# cat file5
hello world
[root@web tmp]#

diff

逐行比较文件不同

-u:

-u:合并格式显示
-c:上下文格式显示

bash 复制代码
[root@web tmp]# diff 1.txt 2.txt
1c1,4
< 112:2223:333213
---
>
> 2
> 3
> 3
3c6,9
< 123123213123:123
---
> 21
> 32
> 112:2223:333213
> 312
5,7c11
< 21312312:S:ADAS:D:!@:#!@:#:@!#:!@#!@
< 12312312123122121312312:!@#!@#!#AS:ASDSAD:!@#!@#:ASDASD:!@#@!
< 213123::::!@#@!#:@!#213:@!#12
---
> 123123
9d12
< 213213:12312:!@#!@:!@312:!@3123:!@312:!@#12:21321312:!23123:!@3
11c14,15
< 2
---
> 213123::::!@#@!#:@!#213:@!#12
> 213213:12312:!@#!@:!@312:!@3123:!@312:!@#12:21321312:!23123:!@3
13,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.txt
1,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

bash 复制代码
[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

bash 复制代码
[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.patch
patching 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.txt

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@web tmp]# cat 6.txt

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:!@#@!

tr

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

-d:删除所有字符

-s:删除重复字符序列,只保留第一个

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中所有的水平、垂直空白

bash 复制代码
[root@web tmp]# cat 5.txt

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@web tmp]# cat 6.txt

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@web tmp]# cat 5.txt | tr -d '[:/]'

2
3
3
123213123123
21
32
1122223333213
312
2112123!@#!@#@!!@#!@#!@#!@#!@
123123
123123!@#213!@#123!@#!@#!#!@#123123@!3123
123213
213123!@#@!#@!#213@!#12
21321312312!@#!@!@312!@3123!@312!@#1221321312!23123!@3
3213123
12312321
21312312SADASD!@#!@#@!#!@#!@
312312312
12312312312
123123123213
123123213123123
12312312123122121312312!@#!@#!#ASASDSAD!@#!@#ASDASD!@#@!
您在 /var/spool/mail/root 中有邮件
[root@web tmp]# tr -s [1-9] < 1.txt
12:23:3213
12:3:2:1:312:3123
123123213123:123
212:123:!@#:!@#:@!:!@#!@:#:!@#:!@:#!@:
21312312:S:ADAS:D:!@:#!@:#:@!#:!@#!@
1231231212312121312312:!@#!@#!#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
[root@web tmp]# tr -s [1-9] <5.txt

2
3
3
12:3:2:1:312:3123
21
32
12:23:3213
312
212: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
1231231212312121312312:!@#!@#!#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]'

bash 复制代码
 ifconfig ens33|grep 'Bcast'|tr -d '[a-zA-Z]'|cut -d: -f2,3,4
bash 复制代码
[root@web tmp]# ifconfig ens33
ens33: 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]#
bash 复制代码
[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地址

bash 复制代码
[root@web tmp]# ifconfig ens33 | grep 'ether' |tr -s ' ' |ls
1.txt        file2                sys-20250717.tar.gz  systemd-private-6f37c267bc534142983b62ad1ab0be9a-bolt.service-LMvltW
2.txt        file3.patch          sys-20250718.tar.gz  systemd-private-6f37c267bc534142983b62ad1ab0be9a-chronyd.service-UWJorp
3.txt        file5                sys-20250720.tar.gz  systemd-private-6f37c267bc534142983b62ad1ab0be9a-colord.service-tLvcX3
5.txt        file6.patch          sys-20250721.tar.gz  systemd-private-6f37c267bc534142983b62ad1ab0be9a-cups.service-LjtpWQ
6.txt        file.patch           sys-20250722.tar.gz  systemd-private-6f37c267bc534142983b62ad1ab0be9a-rtkit-daemon.service-gttbXa
bak.boot     passwd               sys-20250723.tar.gz  vmware-root_1022-2999133054
dir1         swapfile             sys-20250724.tar.gz  vmware-root_1207-3979642956
dir2         sys-20250714.tar.gz  sys-20250728.tar.gz  vmware-root_845-4021653450
EdP.aunSeOi  sys-20250715.tar.gz  sys-20250729.tar.gz  vmware-root_971-4290232077
file1        sys-20250716.tar.gz  sys-20250730.tar.gz

为什么 cut -d ' ' -f3

ether 00:0c:29:97:84:5e txqueuelen 1000 (Ethernet)

得到MAC地址 为什么是f3

bash 复制代码
[root@web tmp]# ifconfig ens33 |grep 'ether' |tr -s ' '|cut -d ' ' -f3
00:0c:29:97:84:5e
您在 /var/spool/mail/root 中有邮件
bash 复制代码
[root@web tmp]# ifconfig ens33|grep broadcast|tr -s ' '|cut -d ' ' -f7
192.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 中有邮件
bash 复制代码
[root@web tmp]# ifconfig ens33|grep broadcast|tr -d '[a-zA-Z]'|tr -s ' '|cut -d ' ' -f4
192.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'

bash 复制代码
[root@web tmp]# grep 'bash$' passwd
root:x:0:0:root:/root:/bin/bash
caozx26:x:1000:1002:caozx26:/home/caozx26:/bin/bash
XOAP:x:1002:1000::/rhome/XOAP:/bin/bash
cao1:x:1004:1223::/home/cao1:/bin/bash
cao2:x:1005:1005::/home/cao2:/bin/bash
xiaocao:x:1006:1006::/home/xiaocao:/bin/bash
xiao6:x:1007:1007::/home/xiao6:/bin/bash
tom:x:1008:1008::/home/tom:/bin/bash
jack:x:1009:1009::/home/jack:/bin/bash
cw01:x:1010:1224::/home/cw01:/bin/bash
sc01:x:1011:1226::/home/sc01:/bin/bash
rs01:x:1012:1225::/home/rs01:/bin/bash
boss01:x:1013:1004::/home/boss01:/bin/bash
cw02:x:1014:1224::/home/cw02:/bin/bash
sc02:x:1015:1226::/home/sc02:/bin/bash
rs02:x:1016:1225::/home/rs02:/bin/bash
harry:x:1017:1017::/home/mahei/redhat/harry:/bin/bash
netasha:x:1018:1018::/home/netasha:/bin/bash
sarsh:x:1019:1228::/home/sarsh:/bin/bash
OOO:x:1020:1020::/home/OOO:/bin/bash
jerry:x:1021:1229::/home/jerry:/bin/bash
kefu:x:1022:1022::/home/kefu:/bin/bash
kefu2:x:1023:1023::/home/kefu2:/bin/bash
user01: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/bash
XOAP:x:1002:1000::/rhome/XOAP:/bin/bash
cao1:x:1004:1223::/home/cao1:/bin/bash
cao2:x:1005:1005::/home/cao2:/bin/bash
xiaocao:x:1006:1006::/home/xiaocao:/bin/bash
xiao6:x:1007:1007::/home/xiao6:/bin/bash
tom:x:1008:1008::/home/tom:/bin/bash
jack:x:1009:1009::/home/jack:/bin/bash
cw01:x:1010:1224::/home/cw01:/bin/bash
sc01:x:1011:1226::/home/sc01:/bin/bash
rs01:x:1012:1225::/home/rs01:/bin/bash
boss01:x:1013:1004::/home/boss01:/bin/bash
cw02:x:1014:1224::/home/cw02:/bin/bash
sc02:x:1015:1226::/home/sc02:/bin/bash
rs02:x:1016:1225::/home/rs02:/bin/bash
harry:x:1017:1017::/home/mahei/redhat/harry:/bin/bash
netasha:x:1018:1018::/home/netasha:/bin/bash
sarsh:x:1019:1228::/home/sarsh:/bin/bash
OOO:x:1020:1020::/home/OOO:/bin/bash
jerry:x:1021:1229::/home/jerry:/bin/bash
kefu:x:1022:1022::/home/kefu:/bin/bash
kefu2:x:1023:1023::/home/kefu2:/bin/bash
user01:x:1024:1024::/home/user01:/bin/bash
[root@web tmp]# grep 'bash$' passwd|grep -v 'root'|cut -d: -f1,2,7
caozx26:x:/bin/bash
XOAP:x:/bin/bash
cao1:x:/bin/bash
cao2:x:/bin/bash
xiaocao:x:/bin/bash
xiao6:x:/bin/bash
tom:x:/bin/bash
jack:x:/bin/bash
cw01:x:/bin/bash
sc01:x:/bin/bash
rs01:x:/bin/bash
boss01:x:/bin/bash
cw02:x:/bin/bash
sc02:x:/bin/bash
rs02:x:/bin/bash
harry:x:/bin/bash
netasha:x:/bin/bash
sarsh:x:/bin/bash
OOO:x:/bin/bash
jerry:x:/bin/bash
kefu:x:/bin/bash
kefu2:x:/bin/bash
user01: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/bash
XOAP    x       /bin/bash
cao1    x       /bin/bash
cao2    x       /bin/bash
xiaocao x       /bin/bash
xiao6   x       /bin/bash
tom     x       /bin/bash
jack    x       /bin/bash
cw01    x       /bin/bash
sc01    x       /bin/bash
rs01    x       /bin/bash
boss01  x       /bin/bash
cw02    x       /bin/bash
sc02    x       /bin/bash
rs02    x       /bin/bash
harry   x       /bin/bash
netasha x       /bin/bash
sarsh   x       /bin/bash
OOO     x       /bin/bash
jerry   x       /bin/bash
kefu    x       /bin/bash
kefu2   x       /bin/bash
user01  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.txt
caozx26 x       /bin/bash
XOAP    x       /bin/bash
cao1    x       /bin/bash
cao2    x       /bin/bash
xiaocao x       /bin/bash
xiao6   x       /bin/bash
tom     x       /bin/bash
jack    x       /bin/bash
cw01    x       /bin/bash
sc01    x       /bin/bash
rs01    x       /bin/bash
boss01  x       /bin/bash
cw02    x       /bin/bash
sc02    x       /bin/bash
rs02    x       /bin/bash
harry   x       /bin/bash
netasha x       /bin/bash
sarsh   x       /bin/bash
OOO     x       /bin/bash
jerry   x       /bin/bash
kefu    x       /bin/bash
kefu2   x       /bin/bash
user01  x       /bin/bash
您在 /var/spool/mail/root 中有邮件
[root@web tmp]# cat abc.txt
caozx26 x       /bin/bash
XOAP    x       /bin/bash
cao1    x       /bin/bash
cao2    x       /bin/bash
xiaocao x       /bin/bash
xiao6   x       /bin/bash
tom     x       /bin/bash
jack    x       /bin/bash
cw01    x       /bin/bash
sc01    x       /bin/bash
rs01    x       /bin/bash
boss01  x       /bin/bash
cw02    x       /bin/bash
sc02    x       /bin/bash
rs02    x       /bin/bash
harry   x       /bin/bash
netasha x       /bin/bash
sarsh   x       /bin/bash
OOO     x       /bin/bash
jerry   x       /bin/bash
kefu    x       /bin/bash
kefu2   x       /bin/bash
user01  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` ```bash [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]# ``` ## 记录 ```bash 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.txt uniq: 1.txt: 没有那个文件或目录 您在 /var/spool/mail/root 中有新邮件 [root@web ~]# cd /tmp [root@web tmp]# uniq 1.txt 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 [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.txt 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 [root@web tmp]# echo hello world | tee file5 hello world 您在 /var/spool/mail/root 中有邮件 [root@web tmp]# cat file5 hello world [root@web tmp]# diff file1 file2 您在 /var/spool/mail/root 中有邮件 [root@web tmp]# diff file2 file3 diff: file3: 没有那个文件或目录 [root@web tmp]# diff text1 text2 diff: text1: 没有那个文件或目录 diff: text2: 没有那个文件或目录 [root@web tmp]# ls 1.txt file3.patch sys-20250718.tar.gz systemd-private-6f37c267bc534142983b62ad1ab0be9a-bolt.service-LMvltW 2.txt file5 sys-20250720.tar.gz systemd-private-6f37c267bc534142983b62ad1ab0be9a-chronyd.service-UWJorp 3.txt file.patch sys-20250721.tar.gz systemd-private-6f37c267bc534142983b62ad1ab0be9a-colord.service-tLvcX3 bak.boot passwd sys-20250722.tar.gz systemd-private-6f37c267bc534142983b62ad1ab0be9a-cups.service-LjtpWQ dir1 swapfile sys-20250723.tar.gz systemd-private-6f37c267bc534142983b62ad1ab0be9a-rtkit-daemon.service-gttbXa dir2 sys-20250714.tar.gz sys-20250724.tar.gz vmware-root_1022-2999133054 EdP.aunSeOi sys-20250715.tar.gz sys-20250728.tar.gz vmware-root_1207-3979642956 file1 sys-20250716.tar.gz sys-20250729.tar.gz vmware-root_845-4021653450 file2 sys-20250717.tar.gz sys-20250730.tar.gz vmware-root_971-4290232077 [root@web tmp]# diff 1.txt 2.txt 1c1,4 < 112:2223:333213 --- > > 2 > 3 > 3 3c6,9 < 123123213123:123 --- > 21 > 32 > 112:2223:333213 > 312 5,7c11 < 21312312:S:ADAS:D:!@:#!@:#:@!#:!@#!@ < 12312312123122121312312:!@#!@#!#AS:ASDSAD:!@#!@#:ASDASD:!@#@! < 213123::::!@#@!#:@!#213:@!#12 --- > 123123 9d12 < 213213:12312:!@#!@:!@312:!@3123:!@312:!@#12:21321312:!23123:!@3 11c14,15 < 2 --- > 213123::::!@#@!#:@!#213:@!#12 > 213213:12312:!@#!@:!@312:!@3123:!@312:!@#12:21321312:!23123:!@3 13,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.txt 1,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 dir2 只在 dir1 存在:file1 只在 dir2 存在:file2 您在 /var/spool/mail/root 中有邮件 [root@web tmp]# copy 1.txt 5.txt bash: 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.patch patching 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.txt 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@web tmp]# cat 6.txt 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@web tmp]# cat 5.txt | tr -d '[:/]' 2 3 3 123213123123 21 32 1122223333213 312 2112123!@#!@#@!!@#!@#!@#!@#!@ 123123 123123!@#213!@#123!@#!@#!#!@#123123@!3123 123213 213123!@#@!#@!#213@!#12 21321312312!@#!@!@312!@3123!@312!@#1221321312!23123!@3 3213123 12312321 21312312SADASD!@#!@#@!#!@#!@ 312312312 12312312312 123123123213 123123213123123 12312312123122121312312!@#!@#!#ASASDSAD!@#!@#ASDASD!@#@! 您在 /var/spool/mail/root 中有邮件 [root@web tmp]# tr -s [1-9] < 1.txt 12:23:3213 12:3:2:1:312:3123 123123213123:123 212:123:!@#:!@#:@!:!@#!@:#:!@#:!@:#!@: 21312312:S:ADAS:D:!@:#!@:#:@!#:!@#!@ 1231231212312121312312:!@#!@#!#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 [root@web tmp]# tr -s [1-9] <5.txt 2 3 3 12:3:2:1:312:3123 21 32 12:23:3213 312 212: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 1231231212312121312312:!@#!@#!#AS:ASDSAD:!@#!@#:ASDASD:!@#@! 您在 /var/spool/mail/root 中有邮件 [root@web tmp]# tr '[1-9]' '[@]' < 5.txt ] ] ] @]:]:]:@:]@]:]@]] ]@ ]] @@]:]]]]:]]]]@] ]@] ]@@]:@]]:!@#:!@#:@!:!@#!@:#:!@#:!@:#!@: @]]@]] @]]@]]:!@#]@]:!@#@]]:!@#!@#:!#!@#:@]]@]]:@!]@]] @]]]@] ]@]@]]::::!@#@!#:@!#]@]:@!#@] ]@]]@]:@]]@]:!@#!@:!@]@]:!@]@]]:!@]@]:!@#@]:]@]]@]@]:!]]@]]:!@] ]]@]@]] @]]@]]]@ ]@]@]]@]:S:ADAS:D:!@:#!@:#:@!#:!@#!@ ]@]]@]]@] @]]@]]@]]@] @]]@]]@]]]@] @]]@]]]@]@]]:@]] @]]@]]@]@]]@]]@]@]@]]@]:!@#!@#!#AS:ASDSAD:!@#!@#:ASDASD:!@#@! [root@web tmp]# ifconfig ens33: 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 0 lo: 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 0 virbr0: 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 ens33 bash: inconfig: 未找到命令... [root@web tmp]# ifconfig ens33 ens33: 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 ens33 ens33: 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' ' f2 cut: 您必须指定一组字节、字符或域的列表 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 ' ' -f3 00:0c:29:97:84:5e 您在 /var/spool/mail/root 中有邮件 [root@web tmp]# ifconfig ens33 | grep 'ether' |tr -s ' ' |ls 1.txt file2 sys-20250717.tar.gz systemd-private-6f37c267bc534142983b62ad1ab0be9a-bolt.service-LMvltW 2.txt file3.patch sys-20250718.tar.gz systemd-private-6f37c267bc534142983b62ad1ab0be9a-chronyd.service-UWJorp 3.txt file5 sys-20250720.tar.gz systemd-private-6f37c267bc534142983b62ad1ab0be9a-colord.service-tLvcX3 5.txt file6.patch sys-20250721.tar.gz systemd-private-6f37c267bc534142983b62ad1ab0be9a-cups.service-LjtpWQ 6.txt file.patch sys-20250722.tar.gz systemd-private-6f37c267bc534142983b62ad1ab0be9a-rtkit-daemon.service-gttbXa bak.boot passwd sys-20250723.tar.gz vmware-root_1022-2999133054 dir1 swapfile sys-20250724.tar.gz vmware-root_1207-3979642956 dir2 sys-20250714.tar.gz sys-20250728.tar.gz vmware-root_845-4021653450 EdP.aunSeOi sys-20250715.tar.gz sys-20250729.tar.gz vmware-root_971-4290232077 file1 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 ' ' -f3 00:0c:29:97:84:5e 您在 /var/spool/mail/root 中有邮件 [root@web tmp]# ifconfig ens33|grep brodecast 您在 /var/spool/mail/root 中有邮件 [root@web tmp]# brodacast bash: brodacast: 未找到命令... [root@web tmp]# ifconfig ens33 ens33: 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 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 ' ' -f7 192.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 ' ' -f4 192.168.235.255 您在 /var/spool/mail/root 中有邮件 [root@web tmp]# grep 'bash$' passwd root:x:0:0:root:/root:/bin/bash caozx26:x:1000:1002:caozx26:/home/caozx26:/bin/bash XOAP:x:1002:1000::/rhome/XOAP:/bin/bash cao1:x:1004:1223::/home/cao1:/bin/bash cao2:x:1005:1005::/home/cao2:/bin/bash xiaocao:x:1006:1006::/home/xiaocao:/bin/bash xiao6:x:1007:1007::/home/xiao6:/bin/bash tom:x:1008:1008::/home/tom:/bin/bash jack:x:1009:1009::/home/jack:/bin/bash cw01:x:1010:1224::/home/cw01:/bin/bash sc01:x:1011:1226::/home/sc01:/bin/bash rs01:x:1012:1225::/home/rs01:/bin/bash boss01:x:1013:1004::/home/boss01:/bin/bash cw02:x:1014:1224::/home/cw02:/bin/bash sc02:x:1015:1226::/home/sc02:/bin/bash rs02:x:1016:1225::/home/rs02:/bin/bash harry:x:1017:1017::/home/mahei/redhat/harry:/bin/bash netasha:x:1018:1018::/home/netasha:/bin/bash sarsh:x:1019:1228::/home/sarsh:/bin/bash OOO:x:1020:1020::/home/OOO:/bin/bash jerry:x:1021:1229::/home/jerry:/bin/bash kefu:x:1022:1022::/home/kefu:/bin/bash kefu2:x:1023:1023::/home/kefu2:/bin/bash user01: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/bash XOAP:x:1002:1000::/rhome/XOAP:/bin/bash cao1:x:1004:1223::/home/cao1:/bin/bash cao2:x:1005:1005::/home/cao2:/bin/bash xiaocao:x:1006:1006::/home/xiaocao:/bin/bash xiao6:x:1007:1007::/home/xiao6:/bin/bash tom:x:1008:1008::/home/tom:/bin/bash jack:x:1009:1009::/home/jack:/bin/bash cw01:x:1010:1224::/home/cw01:/bin/bash sc01:x:1011:1226::/home/sc01:/bin/bash rs01:x:1012:1225::/home/rs01:/bin/bash boss01:x:1013:1004::/home/boss01:/bin/bash cw02:x:1014:1224::/home/cw02:/bin/bash sc02:x:1015:1226::/home/sc02:/bin/bash rs02:x:1016:1225::/home/rs02:/bin/bash harry:x:1017:1017::/home/mahei/redhat/harry:/bin/bash netasha:x:1018:1018::/home/netasha:/bin/bash sarsh:x:1019:1228::/home/sarsh:/bin/bash OOO:x:1020:1020::/home/OOO:/bin/bash jerry:x:1021:1229::/home/jerry:/bin/bash kefu:x:1022:1022::/home/kefu:/bin/bash kefu2:x:1023:1023::/home/kefu2:/bin/bash user01:x:1024:1024::/home/user01:/bin/bash [root@web tmp]# grep 'bash$' passwd|grep -v 'root'|cut -d: -f1,2,7 caozx26:x:/bin/bash XOAP:x:/bin/bash cao1:x:/bin/bash cao2:x:/bin/bash xiaocao:x:/bin/bash xiao6:x:/bin/bash tom:x:/bin/bash jack:x:/bin/bash cw01:x:/bin/bash sc01:x:/bin/bash rs01:x:/bin/bash boss01:x:/bin/bash cw02:x:/bin/bash sc02:x:/bin/bash rs02:x:/bin/bash harry:x:/bin/bash netasha:x:/bin/bash sarsh:x:/bin/bash OOO:x:/bin/bash jerry:x:/bin/bash kefu:x:/bin/bash kefu2:x:/bin/bash user01: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/bash XOAP x /bin/bash cao1 x /bin/bash cao2 x /bin/bash xiaocao x /bin/bash xiao6 x /bin/bash tom x /bin/bash jack x /bin/bash cw01 x /bin/bash sc01 x /bin/bash rs01 x /bin/bash boss01 x /bin/bash cw02 x /bin/bash sc02 x /bin/bash rs02 x /bin/bash harry x /bin/bash netasha x /bin/bash sarsh x /bin/bash OOO x /bin/bash jerry x /bin/bash kefu x /bin/bash kefu2 x /bin/bash user01 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.txt caozx26 x /bin/bash XOAP x /bin/bash cao1 x /bin/bash cao2 x /bin/bash xiaocao x /bin/bash xiao6 x /bin/bash tom x /bin/bash jack x /bin/bash cw01 x /bin/bash sc01 x /bin/bash rs01 x /bin/bash boss01 x /bin/bash cw02 x /bin/bash sc02 x /bin/bash rs02 x /bin/bash harry x /bin/bash netasha x /bin/bash sarsh x /bin/bash OOO x /bin/bash jerry x /bin/bash kefu x /bin/bash kefu2 x /bin/bash user01 x /bin/bash 您在 /var/spool/mail/root 中有邮件 [root@web tmp]# cat abc.txt caozx26 x /bin/bash XOAP x /bin/bash cao1 x /bin/bash cao2 x /bin/bash xiaocao x /bin/bash xiao6 x /bin/bash tom x /bin/bash jack x /bin/bash cw01 x /bin/bash sc01 x /bin/bash rs01 x /bin/bash boss01 x /bin/bash cw02 x /bin/bash sc02 x /bin/bash rs02 x /bin/bash harry x /bin/bash netasha x /bin/bash sarsh x /bin/bash OOO x /bin/bash jerry x /bin/bash kefu x /bin/bash kefu2 x /bin/bash user01 x /bin/bash 您在 /var/spool/mail/root 中有邮件 [root@web tmp]# cp *.conf /dir1 cp: 无法获取"*.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]# ```