search similar name using find + skills
1) sample :
find ./ -name '*asd*'
2) more than one sample:
find ./ -name '*asd*' -o -name '*bsc*'
3)使用-size选项可以通过文件大小查找文件。
查找比指定文件大的文件
查找比指定文件小的文件
查找符合给定大小的文件
1
|
find ~ -size 100M
4)给常用find操作取别名 若你发现有些东西很有用,你可以给他取别名。并且在任何你希望的地方执行。
常用的删除a.out文件。
1
2
|
alias rmao= "find . -iname a.out -exec rm {} \;"
|
删除c程序产生的core文件。
1
2
|
alias rmc= "find . -iname core -exec rm {} \;"
5) 12. 通过和其他文件比较修改时间查找文件 显示在指定文件之后做出修改的文件。下面的find命令将显示所有的在ordinary_file之后创建修改的文件。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
|
ls -lrt
total 0
-rw-r----- 1 root root 0 2009-02-19 20:27 others_can_also_read
----r----- 1 root root 0 2009-02-19 20:27 others_can_only_read
-rw------- 1 root root 0 2009-02-19 20:29 ordinary_file
-rw-r--r-- 1 root root 0 2009-02-19 20:30 everybody_read
-rwxrwxrwx 1 root root 0 2009-02-19 20:31 all_for_all
---------- 1 root root 0 2009-02-19 20:31 no_for_all
.
. /everybody_read
. /all_for_all
. /no_for_all
6) 查找5个最大的文件 下面的命令列出当前目录及子目录下的5个最大的文件。这会需要一点时间,取决于命令需要处理的文件数量。
1
|
find . - type f - exec ls -s {} \; | sort -n -r | head -5
|
7) 查找5个最小的文件
方法同查找5个最大的文件类似,区别只是sort的顺序是降序。
1
|
find . - type f - exec ls -s {} \; | sort -n | head -5
在root目录及其子目录下查找passwd文件。
1
2
3
4
5
|
. /usr/share/doc/nss_ldap-253/pam .d /passwd
. /usr/bin/passwd
. /etc/pam .d /passwd
. /etc/passwd
|
在root目录及其1层深的子目录中查找passwd. (例如root — level 1, and one sub-directory — level 2)
|
|
|
|
没有评论:
发表评论