linux find 命令!
一,basic find example
1,find -name snow.png
search for files named snow.png in the current directory
2,find -iname snow.png
case-insensitive search for files named snow.png,Snow.png,SNOW.PNG, in the current directory
3,find / -name *.txt
search for files anywhere on the system that end in .txt
4,find /etc -name *pass*
search ofr files in /etc/ that contaion pass in their name
5,find /home -user joe -group joe
search ofr files owned by the user joe and the group joe in /home
二,find and logical operators
Criteria are ANDed together by default.
Can be OR'd or negated with -o or -not
parentheses can be used to determine logic order,but must be escaped in bash.
find -user joe -not -group joe
find -user joe -o -user jane
find -not ( -user joe -o -user jane )
三,find and permissions
can match ownership by name or id
find / -user joe -o -uid 500
can match octal or symbolic permissions
1,find -perm 755
matches if mode is exactly 755
2, find -perm +222
matches if anyone can write
3, find -perm -222
matches if everyone can write
4, find -perm -002
matches if other can write
四,find and numeric criteria
many find criteria take numeric values
1, find -size 10M
files with a size of exactly 10 megabytes
2, find -size +10M
files with a size over 10 megabytes
3, find -size -10M
files with a size less than 10 megabytes
other modifiers are available such as k for KB,G for GB ,etc
五,find and access times
find can match by inode timestamps
-atime when file was last read
-mtime when file data last changed
-ctime when file data or metadata last change
value given is in days
1, find /tmp -ctime +10
files changed more than 10 days ago
can use a value of minutes
-amin
-mmin
-cmin
find /etc -amin -60
六,executing commands with find
commands can be executed on fond files
command must be preceded with -exec or -ok
-ok prompts before acting on each file
command must end with space;
can use {} as a filename placeholder
find -size +100M -ok mv {} /tmp/largefiles/ ;
find execution examples
1,find -name "*.conf" -exec cp {} {}.orig ;
back up configuration files form the current directory, adding a .orig extension
2, find /tmp -ctime +3 -user joe -ok rm {} ;
prompt ot remove joe's tmp files that are over 3 days old
3, find ~ -perm -002 -exec chmod o-w {} ;
fix other-writabled files in your home directory
4, find /home -type d -ls
do an ls-l style listing of all directories in /home
5, find /data -type f -perm 644 -name *.sh -ok chmod 755 {} ;
find files that end in .sh found in the /data/ directory with a current permission of 644, and ask to make them executable
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/312079/viewspace-1007120/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- linux find命令Linux
- linux find 命令Linux
- linux/unix find命令Linux
- linux中file命令和find命令Linux
- Linux find 命令詳解Linux
- Linux find命令詳解Linux
- Linux精講——find命令Linux
- linux每日命令(20):find命令概覽Linux
- Linux 常用基本命令 findLinux
- (轉)Linux find命令詳解Linux
- Linux下find命令詳解Linux
- Linux Find 命令精通指南Linux
- Linux/Unix重要find命令詳解Linux
- 在 Linux中find命令使用技巧Linux
- linux 查詢檔案命令 findLinux
- Linux下find命令的用法(轉)Linux
- 每天一個linux命令:find命令之xargsLinux
- linux find 命令和 while 命令聯合使用案例LinuxWhile
- find 命令
- find命令
- Linux - find命令常用引數與示例Linux
- linux命令終極系列之(find)(轉)Linux
- Linux下ulimit、find命令使用者LinuxMIT
- 每天一個linux命令(1):find命令之execLinux
- 每天一個 Linux 命令(19):find 命令概覽Linux
- 每天一個 Linux 命令(20):find命令之execLinux
- 每天一個 Linux 命令(21):find命令之xargsLinux
- Linux學習之linux的find命令如何使用?Linux
- find -newer命令
- Linux 命令列:find 的 26 個用法示例Linux命令列
- Linux系統下find、locate命令如何使用?Linux
- Linux中find命令-path -prune用法詳解Linux
- 為什麼要謹慎使用Linux find命令?Linux
- linux中查詢find命令的複雜用法Linux
- linux中強大且常用命令:find、grepLinux
- linux下find,xargs命令詳解和例項Linux
- Linux檔案查詢命令find,xargs詳述Linux
- linux_命令集_tar_find_sed_du_Linux