![]() Let’s repeat our last search with the -R (recursive dereference) option: grep -R -i memfree. We’ve got a symbolic link in this directory, called logs-folder. We can make grep follow symbolic links by using the -R (recursive dereference) option. The output includes the directory and filename of each matching line. Here we’re searching in the current directory “.” and any subdirectories: grep -r -i memfree. Note that you don’t provide a file name on the command line, you must provide a path. To search through nested directories and subdirectories, use the -r (recursive) option. We can check the return code using the $? special parameters: grep -q average geek-1.log echo $? grep -q howtogeek geek-1.log echo $? A result of zero means the string was found, and a result of one means it was not found. The result is passed to the shell as a return value from grep. ![]() ![]() We can cause grep to be completely silent. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |