参数解释:
find命令用来查询某个目录下的文件
几种常用的参数
>>> 学习linux命令,请关注 linux命令大全,学好linux命令,助力您做好linux系统管理。
以下是find命令的演示例子,一起来看看。
[Oracle@localhost testDir]$ cat find.sh
echo "prune:" >> find.out
find . -path "./folder" -prune -o -name "file*" >> find.out
echo "-name:" >> find.out
find . -name "[a-z][a-z]*" >> find.out
echo "-mtime: +3" >> find.out
find . -mtime +3 >> find.out
echo "-mtime: -3" >> find.out
find . -mtime -3 >> find.out
echo "find newer then 1 and older then 2 files:">> find.out
find . -newer "test1.sh" ! -newer "test2.sh" -exec ls -l {} ; >> find.out
echo "-type:" >> find.out
find . -type d >> find.out
echo "except type:" >> find.out
find . ! -type d >> find.out
echo "-size +10c :" >> find.out
find . -size +10c >> find.out
echo "-size -10c :" >> find.out
find . -size -10c >> find.out输出结果:
[oracle@localhost testDir]$ cat find.out
prune:
./folder
-name:
./blank_file
./find.sh
./shelltest.sh
./folder
./folder/file1
./test1.log
./test1.sh
./test2.sh
./main.sh
./find.out
-mtime: +3
./find.sh
./shelltest.sh
./folder
./folder/file1
./test1.sh
./test2.sh
./main.sh
-mtime: -3
.
./blank_file
./test1.log
./find.out
find newer then 1 and older then 2 files:
-rwxr-xr-x 1 oracle oinstall 100 Nov 10 23:08 ./test2.sh
-rwxr-xr-x 1 oracle oinstall 26 Nov 10 22:30 ./main.sh
-type:
.
./folder
except type:
./blank_file
./find.sh
./shelltest.sh
./folder/file1
./test1.log
./test1.sh
./test2.sh
./main.sh
./find.out
-size +10c :
.
./blank_file
./find.sh
./shelltest.sh
./folder
./test1.log
./test1.sh
./test2.sh
./main.sh
./find.out
-size -10c :
./folder/file1