nl
stringlengths
13
387
bash
stringlengths
1
532
Find all files starting from the current directory that match regular expression '.*Message.*\.java'
find . -print | grep '.*Message.*\.java'
Find all files that are less than 50 bytes
find / -size -50c
find all files that do not have read permission to all
find . -type f ! -perm -444
find all the files (under root file system /) that were changed within the last 24 hours
find / -ctime -1
Find all the files that were modified within the last day
find . -mtime -1
Find all files under $d directory and set read-write permission for owner and group and no permission for other for those files
find $d -type f -exec chmod ug=rw,o= '{}' \;
Find all files under current directory and set read permission for group and other for these files
find . -type f -print0 | xargs -0 chmod go+r
find all the files which have been accessed after modifying the file /etc/hosts
find -anewer /etc/hosts
Find all the files whose name is tecmint.txt
find . -name tecmint.txt
find all the files with the name test in the current folder ( case insensitive )
find . -iname test
find all files with pattern` '*.mp3'
find / -name *.mp3
Find all the files without permission 777 under current directory and show a few lines of output from the beginning
find . -type f ! -perm 777 | head
Find all files/directores under /etc filter them by searching for 'test' in their name and run the file command on each of them
find /etc -print0 | grep -azZ test | xargs -0 file
find all foo.bar files in the entire file system and which are present in the same partition as root.
find / -name foo.bar -print -xdev
find all the hidden files in the temp folder
find /tmp -type f -name ".*"
find all the html files in the current folder which have been modified in the last 7 days
find . -mtime -7 -name "*.html" -print
Find all php files in a directory
find . -type f -name "*.php"
Find all read-only files
find / -perm /u=r
Find all regular files in the current directory tree and search them for "example"
find -type f -print0 | xargs -r0 grep -F 'example'
find all regular/normal files in the current folder
find -type f
find all the regular/normal files in the current folder
find -type f
Find all regular files under and below /somepath that have extensions PDF, TIF, TIFF, PNG, JPG, JPEG, BMP, PCX, or DCX, ignoring the case and excluding "*_ocr.pdf" files
find /somepath -type f -iregex ".*\.(pdf\|tif\|tiff\|png\|jpg\|jpeg\|bmp\|pcx\|dcx)" ! -name "*_ocr.pdf" -print0
Find all regular files under current directory tree that were accessed $FTIME days ago
find . -type f -atime $FTIME
find all regular/normal files which have execute permission in current folder and copy them to another folder
cp `find -perm -111 -type f` /usr/local/bin
Find all the SGID bit files whose permissions set to 644 in the file system
find / -perm 2644
Find all SGID files
find / -perm /g=s
Find all the Sticky Bit files whose permission are 551
find / -perm 0551
Find all the Sticky Bit set files whose permission are 551 in the file system
find / -perm 1551
Find all symbolic links in the current directory tree
find -type l
Find all text files in the home directory
find ~/ -name '*.txt'
find all the text files in the home directory
find ~/ -name '*.txt'
find all txt files under the current folder except ./directory folder
find -name "*.js" -not -path "./directory/*"
Find and print detailed information about all regular files in your home directory and below that have only the group permission set
find . -perm g=r -type f -exec ls -l {} \;
Find and remove multiple *.txt files
find . -type f -name "*.txt" -exec rm -f {} \;
Find and remove multiple files such as *.mp3 or *.txt under current directory
find . -type f -name "*.mp3" -exec rm -f {} \;
Find and remove multiple files such as *.mp3 or *.txt under current directory
find . -type f -name "*.txt" -exec rm -f {} \;
Find empty files and directories
find . -empty
Find files/directories in entire file system newer than myfile
find / -newer myfile
Find files and directories modified in last 7 days
find . -mtime -7
Find files/directories named 'foo' under current directory tree without descending into directories named 'foo'
find . -name foo -type d -prune -o -name foo -print
Find files/directories that are owned by the user 'syslog' in entire filesystem
find / -user syslog
Find files/directories under current directory and force xargs to print them one by one
find . | xargs -n 1 echo
Find files created in the last minute; works on Mac OS X
find / -newerct '1 minute ago' -print
Find files ending in "*macs"
find -name '*macs'
Find files ending in "config"
find . -path '*/*config'
find file end with '.txt' in current directory.
find . -name "*.txt"
find files having the extension "bam" in current directory
find . -name "*.bam"
find files in /tmp directory that named are core and deletes them
find /tmp -name core -type f -print | xargs /bin/rm -f
find files in /u/bill directory which are access an 2 to 6 minutes ago
find /u/bill -amin +2 -amin -6
Find files in the current directory and below that are newer than /bin/sh
find . -newer /bin/sh
find files in home directory which are modified yesterday
find ~/ -daystart -type f -mtime 1
find files in the users home directory and for each one, ask the user to confirm to delete the file.
find $HOME/. -name *.txt -ok rm {} \;
Find files smaller than 40 blocks skipping directories on other file systems
find . -size -40 -xdev -print
find files which have all permissions to all the users in the current directory
find . -type f -perm 0777 -print
find files which full path name is /tmp/foo/bar under foo directory and print
find foo -path /tmp/foo/bar -print
find files which full path name is /tmp/foo/bar under foo directory and print
find /tmp/foo -path /tmp/foo/bar -print
Find files whose pathnames end in "f"
find . -path '*f'
find foo, Foo, FOo, FOO, etc.
find . -iname foo
find in the file system for the directories with the name "httpdocs"
find / -type d -name 'httpdocs'
Find mysong.ogg anywhere under the home directory
find $HOME -name 'mysong.ogg'
find non-hidden files (ones that do not start with the period "." chartacter) that were are modified in the last 15 minutes.
find . -mmin -15 \( ! -regex ".*/\..*" \)
Find out all *.sh owned by user vivek
find / -user vivek -name "*.sh"
find regular files in the "mail" folder under the user's home directory, displaying filenames and lines that contain the text "Linux"
find ~/mail -type f | xargs grep "Linux"
find Texinfo source files in /usr/local/doc
find /usr/local/doc -name '*.texi'
find Texinfo source files in /usr/local/doc
find foo -path foo/bar -print
Find text files modified less than 5 days ago
find . 鈥搉ame "*.txt" 鈥搈time 5
force delete all the files which have not been accessed in the last 240 hours in the temp folder
find /tmp/* -atime +10 -exec rm -f {} \;
Get a two column list of all regular .rb files residing in the current directory tree
find . -name "*.rb" -type f -print0 | xargs -0 -n 2 echo
Get a detailed listing of all symbolic links in /usr/bin starting with "z"
find /usr/bin -type l -name "z*" -exec ls -l {} \;
Get a list of directories owned by group ID 100
find / -type d -gid 100
keep only read access to all the files in a directory.
find /path/to/dir ! -perm 0644 -exec chmod 0644 {} \;
keep only read access to all the files in a directory.
find /path/to/dir/ -type f ! -perm 0644 -print0 | xargs -0 chmod 644
list *.bmp and *.txt files under the /home/user/Desktop directory.
find /home/user/Desktop -name '*.bmp' -o -name '*.txt'
List *.pl directories in the current directory tree
find . -name "*.pl" -exec ls -ld {} \;
List .c files in the current directory
find . \( ! -name . -prune \) -name "*.c" -print
List all *.png files/directories under /home/kibab directory
find /home/kibab -name '*.png' -exec echo '{}' ';'
List all cron jobs for current user.
crontab -l
List all directories found in the current directory and below.
find . -type d
List all files bigger than 10000 blocks
find . -type f -size +10000 -exec ls -al {} \;
List all files that have not been read in thirty days or more
find . -type f -atime +30 -print
list all javascipts file which whole name does not contain "directory"
find . -name '*.js' -and -not -path directory
list all javascipts file which whole name does not contain excludeddir
find . -name '*.js' | grep -v excludeddir
list all processes with its PIDs
jobs -l
List all regular files from the current directory tree that were modified less than 60 days ago
find -type f -mtime -60
List all regular files in the current directory tree
find . -type f -print0 | xargs -0 ls -l
List all regular files in the current directory tree
find . -type f | xargs ls -l
List each file or directory in the current directory prefixed by its filesize in bytes and sorted from smallest to largest
du -a --max-depth=1 | sort -n
list files in the directory "$directory" with permissions "$permissions"
find "$directory" -perm "$permissions"
list the regular files in your home directory that were modified yesterday
find ~/ -daystart -type f -mtime 1
list regular file which file name end with '*.c' or '*.sh' in current directory
find . -type f \( -name "*.c" -o -name "*.sh" \)
Locate files that reside in the home directory and have not been accessed in the past 30 days
find $HOME -atime +30
Locate files with user permissions rwx owned by my_user
find . -user my_user -perm -u+rwx
Make directories "~/foo/bar/baz", "~/foo/bar/bif", and "~/foo/boo/bang" as needed
mkdir -p ~/foo/bar/baz ~/foo/bar/bif ~/foo/boo/bang
Pass all the files from the current directory tree as arguments to a single 'echo' command
find . -exec echo {} +
perform a case insensitive search
find / -type d -iname "apt" -ls
Print 'huzzah' if /some/dir/ is empty
find /some/dir/ -maxdepth 0 -empty -exec echo "huzzah" \;
Prints the absolute directory path of the current script preceded by the string "dirname/readlink: "
echo "dirname/readlink: $(dirname $(readlink -f $0))"
Print the directory name of the real full path of "relative/path/to/file" where each symbolic link component must exist
dirname `readlink -e relative/path/to/file`
Print file type of the executable file of command "foo"
file $(which foo)
Print the full path directory name of each "file.ext" found under the current directory
find . -name "file.ext" -execdir pwd ';'