Timeline for How can I use grep to find a word inside a folder?
Current License: CC BY-SA 3.0
14 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Mar 9, 2023 at 15:13 | comment | added | Micah Walter |
I think you want to remove the asterisk: grep -anr 'yourString' .
|
|
Sep 30, 2022 at 1:46 | comment | added | parsley72 |
I ran grep -nr 'yourString*' . and got some files with "binary file matches". You can add --text or -a to prevent this: grep -anr 'yourString*' .
|
|
S May 13, 2016 at 20:30 | history | suggested | Seldom 'Where's Monica' Needy | CC BY-SA 3.0 |
Looks like OP omitted some single quotes accidentally.
|
May 13, 2016 at 18:00 | review | Suggested edits | |||
S May 13, 2016 at 20:30 | |||||
S Dec 18, 2015 at 3:41 | history | suggested | 0x8BADF00D | CC BY-SA 3.0 |
Added explanation for all given parameters
|
Dec 18, 2015 at 2:53 | review | Suggested edits | |||
S Dec 18, 2015 at 3:41 | |||||
Mar 2, 2014 at 19:24 | comment | added | kindasimple | This is a dubious choice of regex. Usta has pointed this out. | |
Mar 27, 2013 at 6:36 | comment | added | usta |
2. In case there are no files in the current directory matching the MobileAppSer* wildcard pattern, grep will receive the argument MobileAppSer* as-is and thus will take it as search for text "MobileAppSe" followed by 0 or more occurrences of "r", so it will attempt to find texts "MobileAppSe", "MobileAppSer", "MobileAppSerr", "MobileAppSerrr", etc. in current directory's files contents - not what the user wants either.
|
|
Mar 27, 2013 at 6:30 | comment | added | usta |
Now let's consider both possibilities for grep -nr MobileAppSer* . 1. Assume we have 3 files in the current directory matching MobileAppSer* wildcard pattern: named MobileAppServlet.java , MobileAppServlet.class , MobileAppServlet.txt . Then grep will be invoked like this: grep -nr MobileAppServlet.class MobileAppServlet.java MobileAppServlet.txt . . It means search for text "MobileAppServlet.class" in files MobileAppServlet.java, MobileAppServlet.txt, and elsewhere in the current directory - which surely isn't what the user wants here.
|
|
Mar 27, 2013 at 6:19 | comment | added | usta |
What's the business with * ? It will either result in shell wildcard expansion (if there are filenames matching the wildcard pattern), or grep will take it as 0-or-more repetition operator for the character preceding * .
|
|
S Mar 23, 2013 at 13:19 | history | suggested | Ryan Leonard | CC BY-SA 3.0 |
Improved formatting and grammar.
|
Mar 23, 2013 at 13:18 | review | Suggested edits | |||
S Mar 23, 2013 at 13:19 | |||||
Feb 5, 2013 at 2:00 | vote | accept | kiki | ||
Dec 17, 2012 at 4:58 | history | answered | Manish Ranjan | CC BY-SA 3.0 |