Get the App
SLTechnology News&Howtos  ›  Servers  › 

Shell find: find files, fuzzy queries, time range queries

Shulou Source: shulou.com Published: 2022-06-03 09:51:57 12月06日 Update

Please refer to: https://www.cnblogs.com/peida/archive/2012/11/16/2773289.html command: find path-option [- print] [- exec-ok command] {}\; example: 1. Specify file query: gec@ubuntu:/mnt/hgfs/GZ1725/7-sys/shell/code$ 2. Fuzzy file query gec@ubuntu:/mnt/hgfs/GZ1725/7-sys/shell/code$

3. Query according to time range:

# find the files under the / opt directory between 2019-1-1 and 2019-9-1, and display the details

Find / opt-name 'jdk*'-newermt' 2019-01-01'!-newermt '2019-09-01'-type f | xargs ls-l

-rwxr-xr-x. 1 root root 72087592 March 14 2019. / jdk-6u45-linux-x64.bin

-newermt:mt is an optional parameter [a, c, m, t], a:atime, that is, access time. C:ctime, that is, change time, m:mtime, that is, modification time, t:ttime, that is, objective absolute time, exists only as a reference attribute, and the format is yyyy-MM-dd hh:mm:ss.

-type f: specify a file, not a directory

-type d: specify a folder

# find the files 2 days ago in the / opt directory and display the details

Find / opt-ctime + 2 | xargs ls-l

Lrwxrwxrwx. 1 root root 17 March 14 2019 / opt/apr/apr/lib/libapr-1.so-> libapr-1.so.0.5.0

Lrwxrwxrwx. 1 root root 17 March 14 2019 / opt/apr/apr/lib/libapr-1.so.0-> libapr-1.so.0.5.0

-rwxr-xr-x. 1 root root 72087592 March 14 2019 / opt/jdk-6u45-linux-x64.bin

Tags: File time query directory details scope between examples parameters commands objective properties folders formats references Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Redmi OPPO Reno Shulou Technology Linux Huawei