![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
find
Frequently-Asked QuestionsAttention, find est celui que l'on trouve sur AIX 5.3. Pour plus d'information au sujet de cette faq, contactez Jean-Louis BICQUELET
FAQ Revised: Monday 10 January 2011 15:54:59
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 {} \;
La version pour comprimer tous les fichiers de plus de 300 jours est:
find $1 \( -name '*' \) -atime +300 -exec gzip {} \;
Pour décomprésser:
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
Une deuxième solution est:
find . -name "*.dat" -exec rm {} \;
find . -inum 12289 -exec rm {} \;
find . -type d -exec chmod 755 {} \;
Pour les fichiers ont fait de même:
find . -type f -exec chmod 644 {} \;Il est possible de limiter la profondeur de la recherche en utilisant l'option maxdepth. Avec un niveau 1, on modifie les droits des répertoires se trouvant dans le répertoire courrant. Avec 2, on va jusqu'au niveau 2.
find . -maxdepth 1 -type d -exec chmod 750 {} \; ls -l total 20 drwxr-x--- 9 jlb jlb 4096 2009-08-11 14:50 dev drwxr-x--- 6 jlb jlb 4096 2009-08-08 10:05 prep drwxr-x--- 6 jlb jlb 4096 2009-08-12 10:39 prod -rw-rw-rw- 1 jlb jlb 768 2009-08-12 11:15 README drwxr-x--- 2 jlb jlb 4096 2009-08-12 11:08 tpl
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.
Il existe de plus, deux options permettant de gérer les liens symboliques ou non:
-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-2009 Jean-Louis BICQUELET
This list of questions and answers was generated by makefaq.