![]() To get rid of error redirect to /dev/null for example grep PATH ~/.* 2>/dev/null Using grep PATH ~/.* you'll see all occurrence, including line with searching keyword. So this search for string "PATH" listing name of the files below the user's home directory, only for files that start with a dot. You can think like this, for example using grep. How can I search all the files in a directory (and not its subdirectories) using grep? Why does using wildcards to specify multiple files to search in for work with. Please give me an explanation on the workings of grep that would explain the behavior of commands in (2).Įdit: Let me be more specific. ![]() ![]() I believe that this is what grep does when you pass a directory to it in place of a file. Why am I not being able to use grep on a directory, as in (1), when I should be able to? I've seen that done in plenty examples on the Internet.Įdit: When I say "using grep on a directory", I mean "search in all the files in that directory excluding its subdirectories". I tried using the -s option, but to no avail. Only the errors are printed, I don't get the matching lines. Grep "string" * gives me the errors: grep: data: Is a directory Next, I tried running grep on multiple files. Is supposed to be able to do this, I've read, but it gives me the error: I want to search for a string of text in all files in a directory (and not its subdirectories I know the -r option does that, but that is not what I want). ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |