![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
find
Frequently-Asked QuestionsBeware, find used in this faq is the AIX 5.3 version. For more information, please contact Jean-Louis BICQUELET
FAQ Revised: Monday 10 January 2011 15:56:09
find . * -exec cp {} new_dir \;
find . -name 'cftsu*' -exec rm {} \;
find . -name "*.txt" -exec chmod o+r '{}' \;
#find /var/spool/mqueue -mtime +2 -exec rm {} \;
find rep \( -name '*' \) -exec gzip {} \;
To compress files older than 300 days use:
find $1 \( -name '*' \) -atime +300 -exec gzip {} \;
To uncompress :
find . -name '*.gz' -exec /usr/local/bin/gunzip {} \;
find rep \( -name "*.dat" \) -type f -print | xargs -e rm -f find rep \( -name "*.bak" -o -name "*.BAK" -o -name core -o -name a.out -o -name "*.o" \) -type f -print | xargs -e rm -f
You also can use :
find . -name "*.dat" -exec rm {} \;c>commands
find /cft -user cft -exec chown cftssl {} \;
find . -not \( -name "*,v" -o -name ".*,v" \) '{}' \; -print
Options possibles:
find . -exec grep "www." '{}' \; -print find . -exec grep -q "www." '{}' \; -print
find . -name "*.pdf" -print find . -name \*.pdf -print
find . -nouser -print find . -nogroup -print
find . -mtime -2 -print
find . -mmin -10 -ls 5 200 -rw-rw---- 1 root system 204800 Jan 10 14:25 ./lvmt.log
find /var/spool/mqueue -mtime +2 | wc -l 22342
find . -perm 0600 -print
find . -ls -long .. 1376 2 -r--r----- 1 root system 1369 Jun 12 17:01 /etc/sudoers 1435 2 -r--r----- 1 root system 1161 Mar 25 13:53 /etc/sudoers.rpmsave
-name must be quoted when using wildcards -type e.g. f=file d=directory l=link -user name or UID -group name or GID -nogroup group doesn' xist in the group database -perm specify permissions -size rounded up to next 512 byte block or use c to specify bytes -atime last time file was read -ctime last time file's owner or permissions were changed -mtime last time file was modified -newer find files newer than given file -delete remove files found -ls gives same output as ls -dgils -print displays results of find command -exec command {} \; to execute a command; note the required syntax -ok use instead of exec to be prompted before command is executed -depth starts at lowest level in directory tree rather than root of given directory -prune used when you want to exclude certain subdirectories -cpio Device Writes the current file to the specified device in the cpio command format. -ea Evaluates to the value True if file has either access control information (ACL) or Extended attributes (EA) set. -follow Causes symbolic and hard links to be followed. -fstype Type Evaluates to the value True if the file system to which the file belongs is of the specified type, where the Type variable has a value of jfs (journaled file system) or nfs (network file system). -inum n Evaluates to the value True if file has an i-node matching the value of the n variable.
You also have options that behave differently with links:
-H Cause the file information and file type evaluated for each symbolic link encountered on the command line to be those of the file referenced by the link, and not the link itself. If the referenced file does not exist, the file information and type shall be for the link itself. File information for all symbolic links not on the command line shall be that of the link itself. -L Cause the file information and file type evaluated for each symbolic link to be those of the file referenced by the link, and not the link itself.
find ddl emc ssl -print
Copyright (c) 2006-2011 Jean-Louis BICQUELET
This list of questions and answers was generated by makefaq.