nl
stringlengths
13
387
bash
stringlengths
1
532
Search for "Stock" in all *.java files from the current directory tree
find . -name "*.java" | xargs grep "Stock"
Search for "YOURSTRING" in all files under current directory
grep YOURSTRING `find .`
Search for "facebook\|xing\|linkedin\|googleplus" in "access-log.txt" and print a count of the unique entries
grep -ioh "facebook\|xing\|linkedin\|googleplus" access-log.txt | sort | uniq -c | sort -n
search for "flac" files in current folder using regular expressions
find ./ -regex "./cmn-.\.flac"
Search for "foo" in every file in the current directory and number the output
grep foo * | nl
Search for "largecalculation" in all processes owned by the current user
ps -u `whoami` | grep largecalculation
search for "message.txt" in the folder .cache/bower and display its contents
find .cache/bower/ -name "message.txt" | xargs cat
Search for "pattern" in all the .c files in the current directory tree
find . -name "*.c" | xargs grep pattern
search for "some_function" in all the python files in the current directory
find . -name \*.py | xargs grep some_function
search for "specified string" in all the php files in the current folder
find . -name “*.[php|PHP]” -print | xargs grep -HnT “specified string”
Search for "vid=123" in all compressed files found under "/my_home" matching "*log.20140226*"
zcat `find /my_home -name '*log.20140226*'`|grep 'vid=123'
Search for "whatever" in all files under /dir directory ensuring white space safety in filenames
find /dir -type f -print0 | xargs -0i cat {} | grep whatever
Search for "www.athabasca" in all files under current directory
find . -exec grep "www.athabasca" '{}' \; -print
Search for $GROUP at the beginning of each line in /etc/group and print the last colon (':') separated entry with comma replaced with newlines
grep ^$GROUP /etc/group | grep -o '[^:]*$' | tr ',' '\n'
Search for $SEARCH in all regular files under $DIR directory tree and display the number of bytes of the matched output
find $DIR -type f -exec grep $SEARCH /dev/null {} \; | wc --bytes
Search for '/usr/bin/perl' in all regular files under current dirctory tree and also show a long listing of them
find . -type f -exec grep "/usr/bin/perl" {} \; -ls
Search for 'Attached: Yes' in all regular files under '/proc/scsi' directory tree matching the path '/proc/scsi/usb-storage' and show only the matched filenames
find /proc/scsi/ -path '/proc/scsi/usb-storage*' -type f | xargs grep -l 'Attached: Yes'
Search for 'DOGS' in all files with '.txt' extension under ~/documents and also print the file names
find ~/documents -type f -name '*.txt' -exec grep -s DOGS {} \; -print
Search for 'It took' in all $srch1* (case insensitive) files under current directory
find . -iname "$srch1*" -exec grep "It took" {} \; -print
Search for 'Processed Files' in all $srch* (case insensitive) files under current directory
find . -iname "$srch*" -exec grep "Processed Files" {} \; -print
Search for 'String' case insensitively in all files under current directory tree and show the matched lines with their filenames
find . -name * -print0 | xargs -0 grep -iH "String"
Search for 'Text To Find' in all regular files under current directory tree and show the matched files and matched lines with line numbers
find ./ -type f -exec grep -Hn "Text To Find" {} \;
Search for 'class Pool' in all *.java (case insensitive) files under current directory
find -iname '*.java'|xargs grep 'class Pool'
Search for 'example' in all regular files from the current directory
find -maxdepth 1 -type f | xargs grep -F 'example'
Search for 'example' in all regular files from the current directory tree
find -type f -print0 | xargs -r0 grep -F 'example'
Search for 'example' in all regular files under current directory tree and also print the filenames
find . -type f -exec grep "example" '{}' \; -print
Search for 'foo=' in all *.png files under current directory without descending into *.gif and *.svn directories
find . -name "*.png" -prune -o -name "*.gif" -prune -o -name "*.svn" -prune -o -print0 | xargs -0 -I FILES grep -IR "foo=" FILES
Search for 'invalidTemplateName' in all regular files in directories/files taken from the glob pattern './online_admin/*/UTF-8/*' and show the matched lines with the filenames
find ./online_admin/*/UTF-8/* -type f -exec grep -H "invalidTemplateName" {} \;
Search for 'ireg' in all PHP files under 'project' directory tree and show only the files that match
find project -name '*.php' -type f -print0 | xargs -0 grep -l ireg
Search for 'js' in all files under current directory that match 'some string' in their names
find . | grep 'some string' | grep js
Search for 'keyword' in all javascript files under current directory tree excluding all paths that includes the directory 'node_modules'
find ./ -not -path "*/node_modules/*" -name "*.js" | xargs grep keyword
Search for 'mystring' in all *.txt (case insensitive) files under current directory
find . -iname *.txt -exec egrep mystring \{\} \;
Search for 'mystring' in all *.txt files under current directory
find . -name "*.txt" -exec egrep mystring {} \;
Search for 'mystring' in all *.txt files under current directory
find . -name "*.txt" -print0 | xargs -0 egrep mystring
Search for 'mystring' in all *.txt files under current directory
find . -name '*.txt' | xargs egrep mystring
Search for 'mystring' in all *.txt files under current directory
find . -name *.txt | xargs egrep mystring
Search for 'organic' in all files with '.html' extension under ~/html directory
find ~/html/ -name '*.html' -exec grep organic '{}' ';'
Search for 'pattern' in all files with '.cc' extension under current directory tree and show the matched lines with line numbers and filenames
find . -name “*.cc” |xargs grep -n “pattern”
Search for 'pattern' in file 'file' and print the matched lines by separating them with spaces instead of newlines
grep pattern file | tr '\n' ' '
Search for 'pattern_to_search' in all regular files with '.txt' extension under '/directory/containing/files' and show the matched lines along with filenames
find /directory/containing/files -type f -name "*.txt" -exec grep -H 'pattern_to_search' {} +
Search for 'some string' in all *.axvw files under current directory and show the matched lines with line numbers
find . -name '*.axvw' -exec grep -n 'some string' {} +
Search for 'some string' in all *.axvw files under current directory and show the matched lines with line numbers
find . -name '*.axvw' -print0 | xargs -0 grep -n 'some string'
Search for 'some string' in all *js files under current directory and show the matched lines with line numbers
find . -name '*js' -exec grep -n 'some string' {} \;
Search for 'some string' in all *js files under current directory and show the matched lines with line numbers
find . -name '*js' | grep -n 'some string'
Search for 'sometext' in all the files with '.txt' extension under current directory tree and also print the filenames
find . -name '*.txt' -exec grep 'sometext' '{}' \; -print
Searches for 'something' in a large file and prints the matching line
grep -n 'something' HUGEFILE | head -n 1
Search for 'specific string' in all files matching the name pattern '“*.[txt|TXT]”' under current directory tree
find . -name “*.[txt|TXT]” -print | xargs grep “specific string”
Search for 'string' case insensitively in all files under current directory tree and show the matched lines with their filenames
find . -name * | xargs grep -iH "string"
Search for 'string-to-find' in all files under current directory tree and show the matched lines with their filenames
find . -exec grep -H string-to-find {} \;
Search for 'string-to-find' in all files under current directory tree matching the regex 'filename-regex.\*\.html' in their paths and show the matched lines along with the filenames
find . -regex filename-regex.\*\.html -exec grep -H string-to-find {} \;
Search for 'text' in all regular files under current directory tree
find . -type f -exec grep "text" {} /dev/null \;
Search for 'whatIWantToFind' in all files under current directory
find . -exec grep whatIWantToFind {} \;
search for *.log files starting from /
find / -name "*.log"
search for *.log files starting from / (root) and only in the current file system
find / -xdev -name "*.log"
Search for *pattern* in and below current directory
find -name "*pattern*"
Search for .bam files anywhere in the current directory recursively
find . -name "*.bam"
Search for .zip files that are larger than 100M found anywhere in the file system and delete those files.
find / -type f -name *.zip -size +100M -exec rm -i {} \;
search for a cpp directory in current folder and display all its files
find . -type d -name "cpp" -exec find {} -type f \;
search for a file "file" in current folder and display all instances of this file
find -name file -print
search for a function in all python files in the current folder
find . -name '*.py' | xargs grep some_function
Search for a line starting with 'use strict' in all files with '.pl' extension under current directory tree and show the unmatched files only
find . -name '*.pl' | xargs grep -L '^use strict'
Search for a pattern "can't" in all the files with the name "file-containing-can't" in the current directory tree
find . -name "file-containing-can't" -exec grep "can't" '{}' \; -print
search for a regular/normal file "myfile" in the entire file system excluding the folder in excluded_path
find / -path excluded_path -prune -o -type f -name myfile -print
search for a shell script in the current folder and display the current folder path
find . -name onlyme.sh -exec pwd \;
search for a shell script in the current folder and display the current folder path but search from the sub directories
find . -name onlyme.sh -execdir pwd \;
search for a word in all the .C files in the current directory
find . -name "*.c" -exec grep -ir "keyword" {} ";"
search for a word in all the .C files( those having the extension "c") in current directory
find . -type f \( -iname “*.c” \) |grep -i -r “keyword”
search for a word in all c files in the current folder
find . -name '*.c' | xargs grep 'stdlib.h'
search for a word in all files in a directory
find /directory/containing/files -type f -print0 | xargs -0 grep "test to search"
search for a word in all the files in the current directory
find . -exec grep chrome {} +
search for a word in all the files in the current directory
find . -exec grep chrome {} \;
search for a word in all the files in the current directory
find . -type f -exec grep 'needle' {} \;
search for a word in all the files in the current directory
find . | xargs grep 'chrome'
search for a word in all the files in the current directory (case insensitive search)
find . -type f -exec grep 'needle' {} \;
search for a word in all the files in the current directory and display the file paths relative to the current directory
find . -exec grep -l foo {} +
search for a word in all the files in the current directory and display the list of matched files.
find . -type f -exec grep -l 'needle' {} \;
search for a word in all the fies in the current folder
find . -type f -exec grep some_string {} \;
search for a word in all the files in the entire filesystem and display the matched fline along with the file name
find / -type f -exec grep -Hi 'the brown dog' {} +
search for a word in all the files with the extension "ch" in the current folder
find -name '*.[ch]' | xargs grep -E 'expr'
search for a word in all the php files in the current folder and display the count of all matching lines.
find . -name \*.php -type f -exec grep -Hn '$test' {} \+ | wc -l
search for a word in all the php files in the current folder and display the count of all matching lines.
find . -name \*.php -type f -exec grep -Hn '$test' {} \; | wc -l
search for a word in all the php files in the current folder and display the count of all matching lines.
find . -name \*.php -type f -print0 | xargs -0 -n1 grep -Hn '$test' | wc -l
search for a word in all the php files in the current folder and display the matching lines
find . -name \*.php -type f -exec grep -Hn '$test' {} \;
search for a word in all the php files in the current folder and display the matching lines.
find . -name \*.php -type f -print0 | xargs -0 -n1 grep -Hn '$test'
search for a word in all the normal/regular files in the current folder
find . -type f | xargs grep "text"
search for a word in all the regular files in the current folder.
find -type f -print0 | xargs -r0 grep -F 'example'
search for a word in all the regular/normal files in the current folder and display the filename along with the matched text
find . -type f -exec grep -l linux {} \;
search for a word in all the regular/normal files in the entire filesystem. ( + is used to give more than one file as input to the grep command.
find / -type f -exec grep -i 'the brown dog' {} +;
search for a word in all the shell scripts in the current folder and display the matched files.
find . -type f -name "*.sh" -exec grep -l landoflinux {} \;
search for a word in all the shell scripts in the current folder and display the matched files.(case insensitive search in grep commad)
find . -type f -name "*.sh" -exec grep -il landoflinux {} \;
Search for aaa in all files under current directory and count the number of matches
find . -type f -exec grep -o aaa {} \; | wc -l
search for al cpp files in current folder and display distinct parent directory of these files in sorted order
find . -name "*.cpp" -exec dirname {} + | sort -u
search for al cpp files in current folder and display unique parent directory of these files in sorted order
find . -name "*.cpp" -exec dirname {} \; | sort -u
search for all the ".c" files in the folder "/home/david" which have been modified in the last 10 minutes
find /home/david -mmin -10 -name '*.c'
search for all "tif" images in the entire file system
find / -name '*.tif ' –print
Search for all *.conf files in entire file system
find / -type f -name "*.conf"
Search for all *.ogg (case insensitive) files in the $HOME directory that have an access time of greater than 30 days
find $HOME -iname '*.ogg' -atime +30
Search for all .html files in directory "www" and output only the basename (without containing path) of each.
find www -name \*.html -type f -exec basename {} \;
search for all the .o files in the current directory which have permisssions 664 and print them.
find . -name *.o -perm 664 -print
search for all the directories ending with ".mp3" in the file system and move them to the folder /mnt/mp3
find / -iname "*.mp3" -type d -exec /bin/mv {} /mnt/mp3 \;