2013-09-01 19:17:44 +02:00
|
|
|
|
# To find files by case-insensitive extension (ex: .jpg, .JPG, .jpG):
|
2013-08-11 21:37:11 +02:00
|
|
|
|
find . -iname "*.jpg"
|
|
|
|
|
|
2013-08-22 03:34:11 +02:00
|
|
|
|
# To find directories:
|
2013-08-11 21:37:11 +02:00
|
|
|
|
find . -type d
|
|
|
|
|
|
2013-08-22 03:34:11 +02:00
|
|
|
|
# To find files:
|
2013-08-11 21:37:11 +02:00
|
|
|
|
find . -type f
|
|
|
|
|
|
2013-08-22 03:34:11 +02:00
|
|
|
|
# To find files by octal permission:
|
2013-08-11 21:37:11 +02:00
|
|
|
|
find . -type f -perm 777
|
|
|
|
|
|
2013-08-22 03:34:11 +02:00
|
|
|
|
# To find files with setuid bit set:
|
2013-08-11 21:37:11 +02:00
|
|
|
|
find . -xdev \( -perm -4000 \) -type f -print0 | xargs -0 ls -l
|
2013-08-28 12:15:59 +02:00
|
|
|
|
|
|
|
|
|
# To find files with extension '.txt' and remove them:
|
2013-08-28 12:27:44 +02:00
|
|
|
|
find ./path/ -name '*.txt' -exec rm '{}' \;
|
2013-08-28 12:15:59 +02:00
|
|
|
|
|
|
|
|
|
# To find files with extension '.txt' and look for a string into them:
|
|
|
|
|
find ./path/ -name '*.txt' | xargs grep 'string'
|
|
|
|
|
|
|
|
|
|
# To find files with size bigger than 5 Mb and sort them by size:
|
2014-10-19 17:43:43 +02:00
|
|
|
|
find . -size +5M -type f -print0 | xargs -0 ls -Ssh | sort -z
|
2013-08-28 12:15:59 +02:00
|
|
|
|
|
2013-09-01 19:30:44 +02:00
|
|
|
|
# To find files bigger thank 2 MB and list them:
|
2014-10-19 17:43:43 +02:00
|
|
|
|
find . -type f -size +20000k -exec ls -lh {} \; | awk '{ print $9 ": " $5 }'
|
2013-09-21 19:39:46 +02:00
|
|
|
|
|
|
|
|
|
# To find files modified more than 7 days ago and list file information
|
|
|
|
|
find . -type f -mtime +7d -ls
|
|
|
|
|
|
|
|
|
|
# To find symlinks owned by a user and list file information
|
|
|
|
|
find . -type l --user=username -ls
|
|
|
|
|
|
|
|
|
|
# To search for and delete empty directories
|
|
|
|
|
find . -type d -empty -exec rmdir {} \;
|
|
|
|
|
|
|
|
|
|
# To search for directories named build at a max depth of 2 directories
|
|
|
|
|
find . -maxdepth 2 -name build -type d
|
2013-12-05 17:24:29 +01:00
|
|
|
|
|
|
|
|
|
# To search all files who are not in .git directory
|
|
|
|
|
find . ! -iwholename '*.git*' -type f
|
2014-04-02 11:12:09 +02:00
|
|
|
|
|
2016-03-04 10:35:41 +01:00
|
|
|
|
# To find all files that have the same node (hard link) as MY_FILE_HERE
|
2014-10-19 17:43:43 +02:00
|
|
|
|
find . -type f -samefile MY_FILE_HERE 2>/dev/null
|
2016-03-04 10:35:41 +01:00
|
|
|
|
|
|
|
|
|
# To find all files in the current directory and modify their permissions
|
|
|
|
|
find . -type f -exec chmod 644 {} \;
|