Find komutunun iyi kullanım örnekleri aşağıda bulunuyor. Daha fazlası için esofthub'ın blogunu ziyaret edebilirsiniz.
http://esofthub.blogspot.com/2007/07/using-common-unix-find-command_07.html
Find a file or directory
# find . -name TEMP -print
or
# find . -name TEMP -exec echo {} \;
Find core files in this directory tree and remove them
# find . -name "core" -exec rm -f {} \;
Find junk directories and remove their contents recursively
# find . -name "junk" -exec rm -rf {} \;
Find a pattern in a file using the recursive grep (ignore case)
# find . -type f | xargs grep -i MYPATTERN
Find files modified in the past 7 days
# find . -mtime -7 -type f
Find files owned by a particular user
# find . -user esofthub
Find all your writable directories and list them
# find . -perm -0777 -type d -ls
or
# find . -type d -perm 777 -print
Find all your writable files and list them
# find . -perm -0777 -type f -ls
or
#find . -type f -perm 777 -print
Find large file sizes and list them
# find . -type f -size +1000 -ls
or
# find . -type f -size +1000 -print
Find how many directories are in a path (counts current directory)
# find . -type d -exec basename {} \; | wc -l
53
Find how many files are in a path
# find . -type f -exec basename {} \; | wc -l
120
Find all my pipe files and change their permissions to all writable
# find . -name "pipe*" -exec chmod 666 {} \;
Find files that were modified 7 days ago and archive
# find . -type f -mtime 7 | xargs tar -cvf `date '+%d%m%Y'_archive.tar`
Find files that were modified more than 7 days ago and archive
# find . -type f -mtime +7 | xargs tar -cvf `date '+%d%m%Y'_archive.tar`
Find files that were modified less than 7 days ago and archive
# find . -type f -mtime -7 | xargs tar -cvf `date '+%d%m%Y'_archive.tar`
Find files that were modified more than 7 days ago but less than 14 days ago and archive
# find . -type f -mtime +7 -mtime -14 | xargs tar -cvf `date '+%d%m%Y'_archive.tar`
Find files in two different directories having the "test" string and list them
# find esofthub esoft -name "*test*" -type f -ls
Find files in two different directories having the "test" string and list them
# find esofthub esoft -name "*test*" -type f -ls
Find files in two different directories having the "test" string and count them
# find esofthub esoft -name "*test*" -type f -ls | wc -l
12
Find files and directories newer than CompareFile
# find . -newer CompareFile -print
Find files and directories older than CompareFile
# find . ! -newer CompareFile -print
Find files and directories but don't traverse a particular directory
# find . -name RAID -prune -o -print
Find all the files in the current directory
# find * -type f -print -o -type d -prune
Find an inode and remove
# find . -inum 968746 -exec rm -i {} \;
Hiç yorum yok:
Yorum Gönder