Find usage in Linux

Source: Internet
Author: User

Linux find Usage linux common commands find-name april* find files starting with April in the current directory find-name april* fprint file Look for a file starting with April in the current directory and output the result into file Find-name ap*-o-name may* Find files that start with an AP or May find/mnt-name Tom.txt-ftype VFA T under/mnt look for files with name Tom.txt and file system type VFAT find/mnt-name t.txt!   -ftype vfat under/mnt find files with the name Tom.txt and file system type not VFAT find/tmp-name wa* l Look for a file named WA that starts with a type of symbolic link in/tmp find /home-mtime-2 in/home check the files that have been changed in the last two days find/home-atime-1 check the files accessed within 1 days find/home-m Min +60 Check the files that were changed 60 minutes ago at/home find/home-amin +30 Check the files accessed last 30 minutes ago Find/home-newe R tmp.txt in/home update time than tmp.txt near the file or directory Find/home-anewer tmp.txt in/home check access time than Tmp.txt near the file or directory fi Nd/home-used-2 lists files or directories that have been accessed after the file or directory has been modified, Find/home-user CNSCN lists the contents of the/home directory Files or directories in user CNSCN Find/home-uid +501 lists the user's ID number greater than 501 in the/home directoryor directory Find/home-group CNSCN lists the files or directories in the/home group as CNSCN find/home-gid 501 lists the/home group ID in 501 of files or directories find/home-nouser lists files or directories in/home that are not local Users find/home-nogroup list/home Files or directories that are not part of a local group Find/home-name tmp.txt-maxdepth 4 lists Tmp.txt in/home with a depth of up to 3 layers Find/home-name Tmp.txt-min Depth 3 start at the 2nd level find/home-empty look for a file size of 0 or an empty directory find/home-size +512k more than 5   12k files find/home-size-512k less than 512k files find/home-links +2 check hard connections more than 2 files or directories find /home-perm 0700 file or directory with permission 700 Find/tmp-name tmp.txt-exec Cat {} \;find/tmp-name Tmp.tx    T-ok RM {} \;find/-amin-10 # Find files accessed in the last 10 minutes of the system find/-atime-2 # Find files accessed in the last 48 hours of the system find         /-empty # Find files or folders that are empty in the system find/-group Cat # Find files that belong to Groupcat in the system find/-mmin-5 # Find changes in the last 5 minutes of the systemFile Find/-mtime-1 #查找在系统中最后24小时里修改过的文件find/-nouser #查找在系统中属于作废用户的文件find/-user fre D #查找在系统中属于FRED这个用户的文件查当前目录下的所有普通文件---------------------------------------------------------------------------- ----# Find.      -type f-exec Ls-l {} \;-rw-r–r–1 root root 34928 2003-02-25./conf/httpd.conf-rw-r–r–1 Root Root 12959 2003-02-25/conf/magic-rw-r–r–1 root root 2003-02-25./conf.d/readme Check the current directory There are regular files and in the-e x E C option Use the LS-L command to list them ================================================= in the/L o G S directory to find the files that change time before 5th and delete them: $ fi nd logs-type f-mtime +5-exec-ok rm {} \;================================================= query for files modified on the day [[EMAIL&NBSP;PR Otected] class]# find./-mtime-1-type f-exec ls-l {} \;================================================  = Query the file and ask if you want to display [[email protected] class]# find./-mtime-1-type f-ok ls-l {} \; < LS .... /classdb.inc.php >? Y-rw-r–r–1 cnscn cnscn 13709 January 12:22/classdb.inc.php[[email protected] class]# Find/-mtime  -1-type f-ok ls-l {} \; < LS .... /classdb.inc.php >? N[[email protected] class]#================================================= query and give awk to deal with [[email    Protected] class]# who | awk ' {print $ \ t ' $ cnscn pts/0=================================================awk-grep-sed[[email    Protected] class]# Df-k |   awk ' {print '} ' |   Grep-v ' None ' |   sed S "/\/dev\///g" file system sda2sda1[[email protected] class]# df-k |   awk ' {print '} ' | Grep-v ' None ' File system/dev/sda2/dev/sda11) Find all *.h in/tmp and find "Syscall_vector" in these files, and finally print out all filenames that contain "syscall_vector" a) Find/tmp-name "*.h" | Xargs-n50 grep syscall_vectorb) grep syscall_vector/tmp/*.h | Cut-d ': '-f1| Uniq > Filenamec) find/tmp-name "*.h"-exec grep "Syscall_vector" {} \;    -print2) Find/-name filename-exec rm-rf {} \; Find/NAme Filename-ok rm-rf {} \;3) For example to find files larger than 3M on disk: Find. -size +3000k-exec ls-ld {}; 4) Copy something from find to another place find *.c-exec cp ' {} '/tmp '; ' If you have special files, you can use Cpio, or you can use this syntax: Find Dir-name filename-print |   CPIO-PDV newdir6) Look for files changed at 2004-11-30 16:36:37 # a= ' Find./-name ' *php ' | Ls-l–full-time $A 2>/dev/null | grep "2004-11-30 16:36:37"

Find usage in Linux

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.