21篇测试必备的Linux常用命令,每天敲一篇,每次敲三遍,每月一循环,全都可记住!!
https://www.cnblogs.com/poloyy/category/1672457.html
mkdir -p ~/test/cool
touch ~/test/cool/test{1..5}.txt
touch ~/test/cool/{1..3}.sh
chmod 777 *.sh
history > test.txt
ls >> test1.txt
ls >> test1.txt
find ~/test
-print0
find ~/test -print0
查找的文件名最好使用引号包围,可以配合通配符进行查找
find ~/test -name "*.txt"
find ~/test -path "/*cool*/*.txt"
因为 -name 是不能使用 / 的,除非文件名包含了 / , 因为 -name 只能匹配 file_name (即文件名),并不匹配 dir_name (即目录名)
所以想要在指定目录(~/test)下搜索某目录中(/cool)的某文件(.txt),应该使用-path而不是-name
find ~/test -type d
find ~/test -type f
find ~/test -mtime -5
find ~/test -type f -name "*.txt" -mtime +3
find ~/test -type f -name "*.txt" -mmin -5
find ~/test -mmin +10
-mtime +5
-size n[cwbkMG]
b:512字节的块(默认),1b = 512c
c:bytes,指定字节大小
w:等价于两个bytes,1w=2c,一般用户匹配中文
k:平时常说的1kb,1k=1024c=2b
M:1MB,1M=1024k=2048b
G:1GB,1GB=1024MB=2048*1024b
find ~/test -size 0
find ~/test -size -100k
find ~/test -size +1M
find ~/test -size +1k -size -10k
find ~/test -size +1k -a -size -10k
find ~/test -size +1k -o -type f
find ~/test -not -size 0
find ~/test -type f -o -type d
find ~/test -empty -type f
find ~/test -user root
find ~/test -group root