Grepcommand: RecursivelySearchAllFilesForAStringgrepcommand: RecursivelySearchAllFilesForAStringcd/path/to/dirgrep-r & quot; word & quot ;. grep-r & grep command: Recursively Search All Files For A String cd/path/to/dir grep-r "word ". grep-r "string ". ignore case distinctions: grep-ri "word ". to display print only the filenames with GNU grep, enter: grep-r-l "foo ". you can also specify directory name: grep-r-l "foo"/path/to/dir /*. c find command: Recursively Search All Files For A String find command is recommend because of speed and ability to deal with filenames that contain spaces. cd/path/to/dir find. -type f-exec grep-l "word" {}+ find. -type f-exec grep-l "seting" {} + find. -type f-exec grep-l "foo" {}+ Older UNIX version shocould use xargs to speed up things: find/path/to/dir-type f | xargs grep-l "foo" It is good idea to pass-print0 option to find command that it can deal with filenames that contain spaces or other metacharacters: find/path/to/dir-type f-print0 | xargs-0 grep-l "foo"
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service