nl
stringlengths
13
387
bash
stringlengths
1
532
Find all files whose owner is `user1'
find / -user user1
Find all the files whose permissions are 777 in the current directory
find . -type f -perm 0777 -print
Find all the files whose permissions are 777 under current directory
find . -type f -perm 0777 -print
Find all files with '.conf' extension under '/etc' directory going into at most 2 level deep and show the last 10 of them
find /etc -maxdepth 2 -name "*.conf" | tail
Find all files with '.db' extension (case insensitive) that belong to user 'exampleuser' and were modified exactly 7 days ago under '/home' directory tree
find /home -user exampleuser -mtime 7 -iname ".db"
Find all files with '.jpg' extension in the current directory ignoring sub-directories and archive them to a file named jpeg.tgz
find . -maxdepth 1 -iname "*.jpg" | xargs tar -czvf jpeg.tgz
Find all files with '.txt' (case insensitive) extension under $dir directory non-recursively and sort them numerically
find "$dir" -maxdepth 1 -type f -iname '*.txt' | sort -n
Find all files with 644 permission and change the permission to 664
find . -type f -perm 644 -exec chmod 664 {} \;
Find all files with extension .aac in the /home directory tree
find /home -type f -name '*.aac'
find all files with the first letter “e” or “f” and last one x in /usr/bin directory:
find /usr/bin -name [ef]*x
Find all files with the name "MyProgram.c" in the current directory and all of it's sub-directories.
find -name "MyCProgram.c"
find all the files with the name "datainame" in the file system which are bigger than 50MB
find / -size +50M -iname "Dateiname"
Find all files with name "file.ext" under the current working directory tree and print each full path directory name
find `pwd` -name file.ext |xargs -l1 dirname
find all the files with the name september ( case insensitive )
find -iname september
find all files with pattern` '*.mp3' and send output into nameoffiletoprintto file
find / -name *.mp3 -fprint nameoffiletoprintto
Find all files with space in their names under current directory
find . -type f -name '* *'
Find all files with the SUID bit set
find / -perm -u+s
Find all files with the SUID bit set beginning with the root directory
find / -perm -u+s
Find all files with the SUID bit set, starting from /
find / -perm -u+s
find all the files within your home folder accessed more than 100 days ago
find ~ -atime 100
find all files without 777 permision
find / -type f ! perm 777
Find all the files without permission 777
find / -type f ! -perm 777
Find all the files without permission 777 in the file system
find / -type f ! -perm 777
Find all file.ext files/directories under /home/kibab directory and print . for each of them
find /home/kibab -name file.ext -exec echo . ';'
Find all file.ext files/directories under present working directory and print . for each of them
find `pwd` -name "file.ext" -exec echo $(dirname {}) \;
Find all file1 and file9 files/directories under current directory
find . -name file1 -or -name file9
Find all filenames ending with .c in the /usr directory tree
find /usr -name "*.c"
Find all filenames ending with .c in the current directory tree
find -name "*.c"
Find all filenames ending with .c in the current directory tree, case insensitive
find -iname "*.c"
Find all filename.* files/directories under /root/directory/to/search
find /root/directory/to/search -name 'filename.*'
Find all files/directoires that were modified more than 3 days ago under $dir directory tree
find $dir -mtime +3
Find all files/directores that are newer than /etc/motd and conain the string 'top' at the beginning of their names under user's home directory tree
find ~ -name 'top*' -newer /etc/motd
Find all files/directores under '/usr/local' directory tree that case insensitively contain the word 'blast' in their names
find /usr/local -iname "*blast*"
Find all files/directores under '/usr/local' directory tree that contain the word 'blast' in their names
find /usr/local -name "*blast*"
Find all files/directores under /etc and run the file command on each of them
find /etc -print0 | xargs -0 file
Find all files/drectories under '/u/bill' directory tree that have been accessed in the last 2 to 6 minutes
find /u/bill -amin +2 -amin -6
find all the findme.txt files in the file system
find / -name findme.txt -type f -print
Find all first occurrences of directories named '.texturedata' under '/path/to/look/in' directory tree
find /path/to/look/in/ -type d -name '.texturedata' -prune
Finds all folders that contain 'ssh' file and have 'bin' in path.
dirname `find / -name ssh | grep bin`
Finds all folders that contain 'ssh' file and have 'bin' in path.
find / -name ssh|grep bin|xargs dirname
find all foo.bar files in the entire file system
find / -name foo.bar -print
Find all foo.mp4 files in the current directory tree and print the pathnames of their parent directories
find . -name foo.mp4 -exec dirname {} \;
Find all foo.mp4 files in the current directory tree and print the pathnames of their parent directories
find . -name foo.mp4 -printf '%h\n'
Find all foo.mp4 files in the current directory tree and print the pathnames of their parent directories
find ./ -name "foo.mp4" -printf "%h\n"
find all gif files in the file system
find / -name "*gif" -print
Find all hard links to file /path/to/file that exist under the current directory tree
find . -samefile /path/to/file
Find all hard links to file1 under /home directory
find /home -xdev -samefile file1
find all headers file *.h in /nas/projects directory
find /nas/projects -name "*.h"
find all the header files in /usr/include which have been modified in the last 399 days and display the number of lines, number of files, number of characters of all these files
find usr/include -name '*.h' -mtime -399 | wc
Find all hidden directories starting from the current directory
find . -type d -name ".*"
finda all the hidden files excluding those having the extension htaccess
find . -type f \( -iname ".*" ! -iname ".htaccess" \)
Find all hidden files in the current directory
find . -type f -name ".*"
find all hidden files in the current folder which have been modified after profile file
find . -type f -name ".*" -newer .cshrc -print
Find all hidden files starting from the directory given as variable $FOLDER
find $FOLDER -name ".*"
Find all hidden (regular) files under /tmp
find /tmp -type f -name ".*"
Find all hidden files under /tmp
find /tmp -type f -name ".*"
Find all hidden regular files starting from the current directory
find . -type f -name ".*"
Find all hidden regular files under /tmp and below
find /tmp -type f -name ".*"
find all the html files in the current folder
find . -name "*.html"
find all the html files in the current folder and rename them to .var files
find -name '*.html' -print0 | xargs -0 rename 's/\.html$/.var/'
find all the html files in the current folder which have been modified exactly 7 days ago
find . -mtime 7 -name "*.html" -print
find all the html files in the current folder which have been modified excatly 7 days before
find . -mtime 7 -name "*.html" -print
find all the html files in the current folder which have not been modified in the last 7 days
find . -mtime +7 -name "*.html" -print
Find all HTML files starting with letter 'a' in the current directory and below
find . -name a\*.html
Find all HTML files starting with letter 'a' in the current directory and below ignoring the case
find . -iname a\*.html
find all the html files that are acces in the last 24 hours in the current folder
find . -mtime 1 -name "*.html" -print
find all the html files which are modified in the last 7 days
find . -mtime -7 -name "*.html"
find all the html, javascript and text files in the current folder
find . -type f -name "*.htm*" -o -name "*.js*" -o -name "*.txt"
find all html or cgi files in current folder
find ./ -type f -iregex ".*\.html$" -or -iregex ".*\.cgi$"
Find all httpd.conf files in entire file system
find / -name httpd.conf
Find all image.pdf files/directories under ./polkadots
find ./polkadots -name 'image.pdf'
Find all image.pdf files/directories under ./polkadots with null character as the delimiter
find ./polkadots -name "image.pdf" -print0
Find all image.pdf files under ./polkadots
find ./polkadots -type f -name "image.pdf"
Find all index.* files/directories under current directory
find -name 'index.*'
Find all IP addresses in /etc directory files
find /etc -exec grep '[0-9][0-9]*[.][0-9][0-9]*[.][0-9][0-9]*[.][0-9][0-9]*' {} \;
find all java files in the current folder and search for the pattern REGEX
find . -name '*.java' -exec grep REGEX {} \;
find all the javascript files in current folder using regular expressions
find . -regex '.+\.js'
find all javascript files under the current folder
find . -name '*.js'
find all jpg files in current folder
find . -type f -name "*.JPG"
find all jpg files in the current folder
find . -name "*.jpg"
find all the jpg files in the directory /ftp/dir which are bigger than 500KB
find /ftp/dir/ -size +500k -iname "*.jpg"
find all jpg files in the folder which are in the path "/201111/" and sort them based on name
find */201111/* -name "*.jpg" | sort -t '_' -nk2
find all jpg,png,jpeg,pdf,tif,tiff,bmp and other image formats using regular expressions excluding those ending with "_ocr.pdf"
find /somepath -type f -iregex ".*\.(pdf\|tif\|tiff\|png\|jpg\|jpeg\|bmp\|pcx\|dcx)" ! -name "*_ocr.pdf" -print0
find all js files under the build direcotry except build/external and build/log directory.
find build -not \( -path build/external -prune \) -not \( -path build/blog -prune \) -name \*.js
find all js files under the build direcotry except build/external directory.
find build -not \( -path build/external -prune \) -name \*.js
find all js files which path neither ./dir1 nor ./dir2
find . -name '*.js' -not \( -path "./dir1" -o -path "./dir2/*" \)
find all js files which path does not contain ./node_modules/* nor './vendor/*"
find -name '*.js' -not -path './node_modules/*' -not -path './vendor/*'
Find all l files in the 'foo' folder but ones with name like '*Music*' to the 'bar' folder.
find foo -type f ! -name '*Music*' -exec cp {} bar \;
Find all leaf directories that include only one occurrence of "modules"
find -regex '.*/modules\(/.*\|$\)' \! -regex '.*/modules/.*/modules\(/.*\|$\)' -type d -links 2
Find all level 1 subdirectories of the current directory
find . -maxdepth 1 -type d
Find all lines matching "$USER" in "file" and number the output
grep $USER file |nl
find all the links in the current folder and following it to the pointed path
find -L /target -type l
find all the links in the current folder which are broken
find /target -type l -xtype l
find all the links in somedirectory and print them in a single line (to avoid the problem of files having newline in their names)
find "somedir" -type l -print0
Find all links pointing to /path/to/foo.txt
find . -lname /path/to/foo.txt
Find all links to path/to/file
find -L -samefile path/to/file
(Linux specific) Find all loadable modules for current kernel, whose name includes "perf"
find /lib/modules/`uname -r` -regex .*perf.*
find all the log files in the file system
find / -name "*.log"
find all log files larger then 100MB in /home directory and delete them .
find /home -type f -name *.log -size +100M -exec rm -f {} \;
Finds all the log* files in /myDir recursively that are more than 7 days older, skipping already created .bz2 archives and compresses them.
find /myDir -name 'log*' -and -not -name '*.bz2' -ctime +7 -exec bzip2 -zv {} \;