nl
stringlengths
13
387
bash
stringlengths
1
532
Find all files/directories with '.log' extension that belong to the group 'adm' under '/var/log' directory tree
find /var/log -group adm -name "*.log"
Find all files/directories with '.log' extension whose names start with 'app-', have been modified in the last 5 minutes and show the first one found
find /var/log/crashes -name app-\*\.log -mmin -5 -print | head -n 1
Find all files/directories with '.mp4' extension and all regular files with '.flv' extension, sort them according to their names and display the first 500 of them
find /storage -name "*.mp4" -o -name "*.flv" -type f | sort | head -n500
Find all files/directories with '.o' extension under '/lib/modules' directory tree
find /lib/modules -name '*.o'
Find all files/directories with '.tar.gz' extension under $DIR/tmp/daily/ directory tree, sort them numerically and show the last 3 of them
find $DIR/tmp/daily/ -name '*.tar.gz' | sort -n | tail -3
Find all files/directories with '.txt' extension that are less than 100 KB in size under '/home' directory tree
find /home -name "*.txt" -size -100k
Find all files/directories with '.txt' extension under '/home' directory tree that are exactly 100KB in size
find /home -name "*.txt" -size 100k
Find all files/directories with '.txt' extension under '/home' directory tree that are greater than 100KB in size
find /home -name "*.txt" -size +100k
Find all files/directories with '.what_to_find' extension under current directory tree and show the list by excluding paths that contain 'excludeddir1' and 'excludeddir2'
find . -name '*.what_to_find' | grep -v exludeddir1 | grep -v excludeddir2
Find all files/directories with '.xml' extension that start with 'log4j' in their names under '/cygdrive/e/MyDocs/Downloads/work/OATS Domain related/' directory tree, search for files that contain the string 'CONSOLE' in their contents, then search for the string 'ASYNC' in the matched files and display the matched lin...
find "/cygdrive/e/MyDocs/Downloads/work/OATS Domain related/" -iname "log4j*.xml" | xargs -I % grep -ilr "CONSOLE" "%" | xargs -I % grep -H "ASYNC" %
Find all files/directories with 'my key phrase' in their names under current directory
find . -name '*my key phrase*'
Find all files/directories with 644 permission in entire file system
find / -perm 644
Find all files/directories with 664 permission under current directory tree
find -perm 664
Find all files/directories with 755 permission under current directory tree
find ./ -perm 755
Find all files/directories with 777 permission under current directory tree
find . -perm 777 -print
Find all files/directories with case insensitive name pattern $TARGET that are located in minimum 10 level down the current directory
find -mindepth 10 -iname $TARGET
Find all files/directories with execute permission by group or others
find /path -perm /011
Find all files/directories with inode number 16187430 and move them to 'new-test-file-name'
find -inum 16187430 -exec mv {} new-test-file-name \
Find all files/directories with name pattern $nombre that are at most 2 levels down the $DIR_TEMPORAL and $DIR_DESCARGA directories and show only the file names (without parent path) appended with '.torrent'
find "$DIR_TEMPORAL" "$DIR_DESCARGA" -maxdepth 2 -name "$nombre" -printf '%f.torrent\n'
Find all files/directories with permission $permissions under $directory directory tree
find "$directory" -perm "$permissions"
Find all files and directories with permissions 664
find . -perm 664
Find all files/directories with space in their names under $1 directory
find $1 -name '* *'
Find all files/directories with space in their names under /tmp/ directory and rename them by replacing all spaces with _
find /tmp/ -depth -name "* *" -execdir rename " " "_" "{}" ";"
Find all files/directories with space in their names under /tmp/ directory and rename them by replacing all spaces with _
find /tmp/ -depth -name "* *" -execdir rename 's/ /_/g' "{}" \;
Find all files/directories with spaces in their names under ~/Library directory
find ~/Library -name '* *'
find all files beneath the current directory that begin with the letters 'Foo' and delete them.
find . -type f -name "Foo*" -exec rm {} \;
Find all files beneath the current directory that end with the extension .java and contain the characters String ignoring case. Print the name of the file where a match is found.
find . -type f -name "*.java" -exec grep -il string {} \;
Find all files beneath the current directory that end with the extension .java and contain the characters StringBuffer. Print the name of the file where a match is found.
find . -type f -name "*.java" -exec grep -l StringBuffer {} \;
Find all the files called FindCommandExamples.txt of owner root
find / -user root -name FindCommandExamples.txt
Find all files called wp-config.php in the /var/www directory and below
find /var/www/ -name wp-config.php
Find all files changed on the 29th of September, 2008, starting from the current directory
find . -type f -newerct 2008-09-29 ! -newerct 2008-09-30
find all files the current folder which have not been accessed in the last 7 days and which are bigger than 20KB
find . -atime +7 -size +20480 -print
find all the files ending with ".coffee" in the current folder and search for the words "re" in each line
find . -name \*.coffee -exec grep -m1 -i 're' {} \;
find all the files ending with ".foo" in the folder /usr
find /usr -name '*.foo' -print
find all the files ending with "clj" in the current folder and search for a pattern
find . -name '*.clj' -exec grep -r resources {} \;
find all the files ending with "clj" in the current folder and search for a pattern
find . -name *.clj | xargs grep -r resources
find all the files ending with "mkv" in current folder
find -name "*.mkv"
find all the files ending with "rb" and display the first 10000 lines from these files.
find . -name "*rb" -print0 | xargs -0 head -10000
find all the files ending with "~" in current folder and move them to temp folder
find -name '*~' -print0 | xargs -0 -I _ mv _ /tmp/
find all the files ending with .mp3 or .jpg
find . \( -name '*.mp3' -o -name '*.jpg' \) -print
find all the files ending with jpg in current folder and display their count ( case insensitive )
find ./ -iname '*.jpg' -type f | wc -l
find all the files ending with jpg in current folder and display their count ( case insensitive )
find ./ -type f -regex ".*\.[Jj][Pp][gG]$" | wc -l
Find all files except files with '.gz' extension in the current directory non-recursively and compress them with gzip
find . -maxdepth 1 -type f ! -name '*.gz' -exec gzip "{}" \;
Find all files excluding *.gz files in the current directory tree and compress them with gzip
find . -type f ! -name '*.gz' -exec gzip "{}" \;
Find all files files under the current directory except *.txt
find . -maxdepth 1 -type f -not -regex '.*\.txt'
Find all files, folders, symlinks, etc in the current directory recursively
find .
find all files having certain word in its name in the current folder
find . -name "*bsd*" -print
Findx all files having text "texthere" recursively in a current folder, and prints only file names with matching strings.
find -type f -exec grep -l "texthere" {} +
Find all files in "/home/" which contain "string1", "string2" or the host name in its filename
find /home/ -type f -regextype posix-extended -regex ".*(string1|string2|$(hostname)).*"
Finds all files in $LOCATION, prints file names, overwrite files with random content $TIMES times, and finally remove them.
find $LOCATION -print -exec shred $TIMES -u '{}' \;
Find all files in $dir directory (non-recursive) and count them
find "$dir" -maxdepth 1 -type f | wc -l
Find all files in $dir directory without going into sub-directories
find "$dir" -maxdepth 1 -type f
Find all files in the `sourceDir' directory
find sourceDir -mindepth 1 -maxdepth 1
Find all files in the `sourceDir' directory tree
find sourceDir -mindepth 1
Find all files in the `work' directory tree, pass them to grep and search for "profit"
find ./work -print | xargs grep "profit"
Find all files in /dir1 and print only the filenames (not paths)
find ./dir1 -type f -exec basename {} \;
Find all files in /dir1 and print only the filenames (not paths)
find /dir1 -type f -printf "%f\n"
Find all files in the /etc folder that have been modified within the last 30 days and copy them to /a/path/.
find /etc/ -mtime -30 | xargs -0 cp /a/path
Find all files in the /home/ directory tree that are owned by bob
find /home -user bob
Find all files in the /home/ directory tree that were last accessed more than 7 days ago
find /home -atime +7
Find all files in the /home/ directory tree that were last modified less than 7 days ago
find /home -mtime -7
Find all files in /home/user/ that were created or changed 10 minutes ago
find /home/user/ -cmin 10 -print
Find all files in the /myfiles directory tree following symbolic links
find -L /myfiles
Find all files in the /usr directory tree that are owned by group `staff'
find /usr -group staff
find all the files in the /usr folder which have modification date less than or equal to the file "/FirstFile"
find /usr ! -newer /FirstFile -print
find all files in /usr/bin and run the "file" command on them.
find /usr/bin | xargs file
Find all files in the /var/tmp directory tree with uid=1000
find /var/tmp -uid 1000
Find all files in /var/www/html/zip/data/*/*/*/*/* that are older than 90 days
find /var/www/html/zip/data/*/*/*/*/* -type f -mtime +90
Find all files in /var/www/html/zip/data/*/*/*/*/* that are older than 90 days and print only unique parent directory paths
find /var/www/html/zip/data/*/*/*/*/* -type f -mtime +90 -printf "%h\n" | sort | uniq
Finds all files in a '/path' folder and prints long listing for them.
find /path -type f -exec ls -l \{\} \;
find all files in the a direcotry which have been modified in exactly 1 day back
find /home/bozo/projects -mtime 1
find all files in and under the current directory that have read, write and execute permissions set for all users.
find . -perm 777 -print
Find all the files in the current directory
find * -type f -print -o -type d -prune
Find all files in the current directory and below with extension .php and replace "php" with "html" in their names
find ./ -type f -name "*.php" | xargs -r rename "s/php/html/"
find all the files in the current directory and change the permissions to 775.
find . -exec chmod 775 {} \;
find all the files in the current directory and display them
find . -exec echo {} ;
Find all files in the current directory and its sub-directories that have been modified sometime in the last 24 hours.
find . -mtime -1 -prin
find all the files in the current directory and print them excluding those that have the name SCCS.
find . -print -o -name SCCS -prune
Find all files in current directory and search for 'searchName' in those files
find ./ -name "*" | xargs grep "searchName"
Find all files in current directory and search for 'searchName' in those files and show errors for files that are not directly on the current directory
find ./ -name "*" -printf "%f\n" | xargs grep "searchName"
find all files in the current directory and sub-directories that were accessed after modifying /etc/hosts
find -anewer /etc/hosts
find all the files in the current directory and sub-directories, that were edited within the last 1 hour and execute the list command with long listing format
find -mmin -60 -exec ls -l {} \;
find all the files in the current directory and sub-directories whose status was changed after /etc/fstab was modified
find -cnewer /etc/fstab
find all the files in the current directory ending with ".i"
find . -name ".*\.i"
Find all files in current directory excluding hidden files and put the output into full_backup_dir variable
full_backup_dir=$(find . -depth '(' -wholename './.*' ')' -prune -o -print)
find all files in the current directory excluding those that end with .js or have the words .min or console in their name
find . -type f \( -name "*.js" ! -name "*-min*" ! -name "*console*" \)
find all files in the current directory do not display the files which do not have read permission to all users
find . ! -perm -g+r,u+r,o+r -prune
find all the files in current directory of size exactly 6MB.
find . -size 6M
find all the files in current directory of size greater than 10MB and less than 20 MB.
find . -size +10M -size -20M
find all the files in current directory of size greater than 2GB.
find . -size +2G
Find all the files in the current directory recursively whose permissions are 644 and show the first 10 of them
find . -perm 0644 | head
Find all the files in the current directory recursively whose permissions are 777
find . -type f -perm 0777 -print
Find all the files in the current directory recursively whose permissions are not 777
find . -type f ! -perm 777 | head
Find all files in the current directory recursively with "linkin park" in their names and copy them to /Users/tommye/Desktop/LP, preserving path hierarchy
find . -type f -iname "*linkin park*" | cpio -pvdmu /Users/tommye/Desktop/LP
find all the files in the current directory that have the extension "bar" and donot search in the subdirecotries directories.
find . -name *.bar -maxdepth 2 -print
Find all files in current directory that were modified less than 1 day ago excluding hidden files and put the output to full_backup_dir variable
full_backup_dir=$(find . -depth \( -wholename \./\.\* \) -prune -o -mtime -1 -print)
find all the files in the current directory that have the word "bash" in their name
find . -name "*bash*"
Find all files in the current directory tree and count them
find | wc -l
Find all files in the current directory tree containing "foo" in their names
find . -print | grep -i foo
Find all files in the current directory tree except .html, ignoring .svn directories
find . \( -type d -name '.svn' -o -type f -name '*.html' \) -prune -o -print0