nl
stringlengths
13
387
bash
stringlengths
1
532
Search the current directory tree for regular files that contain "string"
find . -type f -printf '"%p"\n' | xargs grep string
Search the current directory tree for regular files that contain "string"
find . -type f | xargs grep string
Search the current directory tree for regular files that were accessed $FTIME days ago
find . -type f -atime $FTIME
Search the current directory tree for regular files that were changed $FTIME days ago
find . -type f -ctime $FTIME
Search the current directory tree for regular files that were modified $FTIME days ago
find . -type f -mtime $FTIME
Search the current directory tree for regular files whose names begin with "orapw"
find . -name "orapw*" -type f
Search the current directory tree for regular files whose names end in ".shtml" or ".css"
find -type f -regex ".*/.*\.\(shtml\|css\)"
Search the current directory tree for regular files whose names end in ".shtml" or ".css"
find . -type f \( -name "*.shtml" -o -name "*.css" \) -print
Search the current directory tree for regular files whose names end in ".shtml" or ".css"
find . -type f \( -name "*.shtml" -or -name "*.css" \)
Search the current directory tree for regular files whose names end in ".shtml" or ".css"
find . -type f | egrep '\.(shtml|css)$'
Search the current directory tree for regular files whose names end in "log"
find `pwd` -name "*log" -type f
Search the current directory tree for regular files whose names match pattern $x
find . -type f -name $x
Search the current directory tree for symbolic links to files matching pattern '*test*'
find . -lname '*test*'
Search the current directory tree for symlinks pointing at other symlinks
find . -type l -xtype l
Search the current directory tree for symlinks whose contents match pattern "*sysdep.c"
find . -lname '*sysdep.c'
Search the current directory tree for TXT files skipping hidden ones
find . -type f \( -iname "*.txt" ! -iname ".*" \)
Search the current directory up to depth level 2 for files and directories
find . -maxdepth 2
Search the current user's home directory and below for all .png files and copy those files in the directory imagesdir.
find ~/ -name *.png -exec cp {} imagesdir \;
Search the current user's home directory and its sub-directories for any files accessed after alldata.tar was last accessed and add them to that same tar archive.
find ~/ -newer alldata.tar -exec tar uvf alldata.tar {} \;
Search the current user's home directory and its sub-directories for any file that ends in .tar-gz and was modified after filename was last modified.
find ~/ -name *.tar.gz -newer filename
Search the current user's home directory and its sub-directories for any file that was modified less than 2 days ago or was modified after filename was last modified.
find ~/ -mtime -2 -o -newer filename
Search the current working directory tree for files whose names start with "fileA_" or "fileB_"
find . -name 'fileA_*' -o -name 'fileB_*'
Search decompressed "filename.gz" for case-insensitive "user-user"
zcat filename.gz | grep -i user-user
Search the dir_data directory and all of its sub-directories for regular files and remove the execute permission for all while adding the write permission for the user.
find ~/dir_data -type f -exec chmod a-x,u+w {} \;
Search directory $CURR_DIR for regular files that were changed, accessed, or modified $FTIME days ago
find ${CURR_DIR} -type f \( -ctime ${FTIME} -o -atime ${FTIME} -o -mtime ${FTIME} \) -printf "./%P\n"
Search directory /Users/david/Desktop/ recursively for regular files
find /Users/david/Desktop/ -type f
Search directory /Users/david/Desktop/ recursively for regular files with extensions .txt, .mpg, .jpg
find /Users/david/Desktop -type f \( -name '*.txt' -o -name '*.mpg' -o -name '*.jpg' \)
Search directory /home/ABCD recursively, starting from one level below, for regular files
find /home/ABCD/ -mindepth 1 -type f -print
Search directories /opt, /usr, /var for regular file foo
find /opt /usr /var -name foo -type f
Search directory /path/to/check/ for regular files
find /path/to/check/* -maxdepth 0 -type f
Search directories /res/values-en-rUS and /res/xml for XML files
find /res/values-en-rUS /res/xml -iname '*.xml'
Search directory /tmp/foo for files containing "/tmp/foo/bar" in their full names
find /tmp/foo -path /tmp/foo/bar -print
Search directories called ' backup ' from /usr directory downwards and print them.
find /usr -type d -name backup -print
Search directory foo for files containing "/tmp/foo/bar" in their full names
find foo -path /tmp/foo/bar -print
Search directory foo for files containing "foo/bar" in their full names
find foo -path foo/bar -print
Search the directories given as arguments to the Bash script for files whose name is not "ss"
find $@ -not -name ss
Search the directory given as variable $d for empty subdirectories
find "$d" -mindepth 1 -prune -empty
Search directory lpi104-6 for files with inode number 1988884
find lpi104-6 -inum 1988884
Search the directories matching pattern "/path/to/some/dir/*[0-9]" for level 1 subdirectories
find /path/to/some/dir/*[0-9] -type d -maxdepth 1
Search the directories that match pattern '/path/to/directory/folder{?,[1-4]?,50}' for .txt files
find /path/to/directory/folder{?,[1-4]?,50} -name '*.txt'
Search directory tree $DIR for *.txt files
find "$DIR" -name \*.txt
Search directory tree $DIR for *.txt files
find "${DIR}" -name "*.txt"
Search directory tree $DIR for *.txt files
find $DIR -name "*.txt"
Search directory tree $DIR for *.txt files
find $DIR -name "*.txt" -print
Search directory tree `MyApp.app' for directories whose name is 'Headers' and delete them
find -d MyApp.app -name Headers -type d -exec rm -rf "{}" \;
Search directory tree `MyApp.app' for directories whose name is 'Headers' and delete them
find MyApp.app -name Headers -type d -delete
Search directory tree `MyApp.app' for directories whose name is 'Headers' and delete them
find MyApp.app -name Headers -type d -exec rm -rf "{}" \;
Search directory tree `MyApp.app' for directories whose name is 'Headers' and delete them in an optimized way
find -d MyApp.app -name Headers -type d -exec rm -rf {} +
Search directory tree `MyApp.app' for directories whose name is 'Headers' and delete them in an optimized way
find -d MyApp.app -name Headers -type d -print0 | xargs -0 rm -rf
Search directory tree `foo' for files named `Headers'
find foo -name Headers
Search directory tree /srv/${x} for regular files accessed at least 10080 minutes ago, and remove those files
find /srv/${x} -mindepth 1 -type f -not -amin -10080 -exec rm {} \;
Search directory trees /tmp and /var/tmp for "testfile.txt"
find /tmp /var/tmp -iname "testfile.txt"
Search the directory tree /tmp for regular files using zero delimiter for output
find /tmp -type f -print0
Search directory trees /usr/local/man and /opt/local/man for files whose names begin with 'my'
find /usr/local/man /opt/local/man -name 'my*'
Search directory trees /usr/share/doc, /usr/doc, and /usr/locale/doc for files named 'instr.txt'
find /usr/share/doc /usr/doc /usr/locale/doc -name instr.txt
Search the directory tree given as variable $dir for regular files
find $dir -type f
Search the directory tree given as variable $root_dir for regular files
find $root_dir -type f
Search the entire file hierarchy for any file that begins with zsh and exists on the ext3 file systems.
find / -fstype ext3 -name zsh*
Search the entire file hierarchy for files ending with '~' and print all matches except for those with '/media' in their pathnames.
find / -name "*~" | grep -v "/media"
Search the entire file hierarchy for files larger than 100 megabytes and delete them.
find / -size +100M -exec /bin/rm {} \;
Search the entire file system for .jpg files.
find / -name “*.jpg”
Search the entire file system for any file that is writable by other.
find / – perm -0002
search the entire file system for the file "jan92.rpt"
find / -name jan92.rpt -print
Search every directory except the subdirectory excluded_path for a regular file 'myfile'
find / -path excluded_path -prune -o -type f -name myfile -print
Search everywhere for a file called `httpd.conf' that is newer than /etc/apache-perl/httpd.conf
find / -name httpd.conf -newer /etc/apache-perl/httpd.conf
Search everywhere for directories named `root'
find / -type d -name root
Search everywhere for files changed within the last minute
find / -newerct '1 minute ago' -print
Search everywhere for hidden file `.profile'
find / -name .profile
search the file "myfile.txt" in home folder
find "$HOME/" -name myfile.txt -print
Search file /etc/logs/Server.log for lines containing "Error"
find /etc/logs/Server.log -exec grep Error {} \; -print
Search file aaa from current direcoty downwards and print it .
find . -name aaa -print
Search the files from the current directory tree for "chrome"
find . -exec grep chrome {} +
Search the files from the current directory tree for "chrome"
find . -exec grep chrome {} \;
Search the files from the current directory tree for "chrome"
find . | xargs grep 'chrome'
Search the files from the current directory tree for "chrome"
find . | xargs grep 'chrome' -ls
Search the files from the current directory tree for text "documentclass"
find . -type f -print0 | xargs -0 grep -H 'documentclass'
Search the files from directory tree "dirname" for string "foo"
find dirname -print0 | xargs -0 grep foo
Search the files from directory tree "dirname" for string "foo"
find dirname -exec grep foo {} +
Search the file hierarchy for files larger than 100000 KB without searching any mounted removable media
find / -path /media -prune -o -size +200000 -print
Search the files in the current directory tree for lines containing string "vds admin"
find . -exec grep -i "vds admin" {} \;
Search the files in the current directory tree that are named "string to be searched" for "text"
find . -name "string to be searched" -exec grep "text" "{}" \;
search files in the file system excluding those in the paths "10_Recommended" and "/export/repo"
find / -name whatever -not -path "/10_Recommended*" -not -path "/export/repo/*"
search files in the folder /home which have been modified after /tmp/after and before /tmp/before
find /home/ -type f -newer /tmp/after -not -newer /tmp/before
search the file myfile.txt in the current folder
find . -name myfile.txt -print
Search the files of the current directory tree for string "searched-string"
find . | xargs grep "searched-string"
Search the files residing in the current directory tree whose names contain "bills" for "put"
find . -name "*bills*" -print0 | xargs -0 grep put
Search the files residing in the current directory tree whose names contain "bills" for "put"
find . -name '*bills*' -exec grep -H "put" {} \;
Search the files residing in the current directory tree whose names contain "bills" for "put"
find . -name '*bills*' -exec grep put {} \;
Search the file system for regular files whose names are shorter than 25 characters
find / -type f -regextype posix-extended -regex '.*/.{1,24}$'
Search the file system for regular files whose names are shorter than 25 characters
find / -type f | egrep '.*/.{1,24}$'
Search the file system for regular files whose names are shorter than 25 characters
find / -type f| egrep -o "/[^/]{0,24}$" | cut -c 2-
Search the file system for regular files whose names are shorter than 25 characters
find / -type f|egrep "/[^/]{0,24}$"
Search the files under and below /directory/containing/files for "pattern_to_search"
find /directory/containing/files -type f -exec grep -H 'pattern_to_search' {} +
Search the files under and below /directory/containing/files for "text to search"
find /directory/containing/files -type f -print0 | xargs -0 grep "text to search"
Search folder /home/ABCD/ recursively for regular files
find /home/ABCD/ -type f -print
Search for " 000" in the hex dump of "file-with-nulls"
od file-with-nulls | grep ' 000'
Search for "#define" in all files in the current directory, excluding backup files *~, *.orig, *.bak
find . -maxdepth 1 ! -regex '.*~$' ! -regex '.*\.orig$' \ ! -regex '.*\.bak$' -exec grep --color "#define" {} +
Search for "1234567890" in every gzip file modified between 8:00 and 9:00 on 2014-04-30
find . -newermt '2014-04-30 08:00:00' -not -newermt '2014-04-30 09:00:00' |xargs gunzip -c | grep 1234567890
Search for "CONFIG_64BIT" in gzip compressed file "/proc/config.gz"
zcat /proc/config.gz | grep CONFIG_64BIT
Search for "LOG" in jsmith's home directory tree
find ~jsmith -exec grep LOG '{}' /dev/null \; -print