Linux find命令详解

不递归查找 find -maxdepth 1

例如只查找当前目录下的文件:
(比StartWriting.bat新,比HexoS.bat旧的文件)

1
find . -maxdepth 1 -newer StartWriting.bat \! \( -newer HexoS.bat \)

运行效果:

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
[root@localhost exam]# ls -ltr --full-time
总用量 3640
-rw-r--r--. 1 root root 422 2021-03-19 21:12:12.566962591 +0800 StartWriting.bat
drwxr-xr-x. 2 root root 4096 2021-03-19 21:12:12.566962591 +0800 scaffolds
-rw-r--r--. 1 root root 817 2021-03-19 21:12:12.566962591 +0800 package.json
-rw-r--r--. 1 root root 376 2021-03-19 21:12:12.566962591 +0800 HexoSTest.bat
-rw-r--r--. 1 root root 576 2021-03-19 21:12:12.566962591 +0800 HexoD.bat
-rw-r--r--. 1 root root 158 2021-03-19 21:12:12.566962591 +0800 FM.properties
-rw-r--r--. 1 root root 3093 2021-03-19 21:12:12.566962591 +0800 _config.yml
drwxr-xr-x. 3 root root 4096 2021-03-19 21:12:12.636962591 +0800 themes
drwxr-xr-x. 9 root root 4096 2021-03-19 21:12:12.636962591 +0800 source
-rwxr--r--. 1 root root 174 2021-03-19 21:16:37.816962490 +0800 hexos.sh
drwxr-xr-x. 308 root root 8192 2021-03-19 21:19:12.036962431 +0800 node_modules
-rw-r--r--. 1 root root 170424 2021-03-19 21:19:12.746962431 +0800 package-lock.json
-rw-r--r--. 1 root root 3498022 2021-03-22 20:29:10.927984900 +0800 db.json
-rw-r--r--. 1 root root 431 2021-03-22 20:52:44.997984360 +0800 HexoS.bat
[root@localhost exam]# find . -maxdepth 1 -newer StartWriting.bat \! \( -newer HexoS.bat \)
./HexoS.bat
./source
./themes
./hexos.sh
./node_modules
./db.json
./package-lock.json
[root@localhost exam]#