The grep command is a lot more versatile than I remembered. If you don't want to see file names when you grep on multiple files, use -h: grep -wh cats * If you want your finds to include the line number, just add -n as in: $ grep -nw cats wish-list less ,pg and more commands are used for dividing a long file into readable bits. ‘sort’ command sorts out the content of a file alphabetically. The grep command's -w option is explained in the man page as searching for "the expression as a word as if surrounded by \" and it does just that. The grep command can be used to find strings and values in a text document. If you want to find instances of "I want cats" in a large file of personal aspirations while avoiding "I want catsup", either of these commands would work just fine: $ cat wish-list The -w and \ options for selecting whole words also work for phrases. Besides, these options wouldn't have a chance of finding your target text if it appeared inside quotes or following by some character other than a blank while still clearly a whole word: $ grep -w cat program.c This sure beats looking for a whole word by grepping for " cat ", "^cat " and " cat$". $ grep "\" /usr/dict/wordsĮither of these tricks will keep you from getting "catharsis" and "catatonic" when you only want lines containing "cat". Here, is the flag: -e enables selection of every process on the system. For example, the following command will filter traffic related to the 192.168.1.0/24 network. ps command is used to show information concerning a selection of the active processes running on a Linux system, you can use it with the grep command to check Apache service uptime as follows. Alternatively, use the net qualifer if you want to filter out traffic to or from an entire network. Don't forget to put your expression in quotes as shown. For example, to filter traffic related to the host at IP address 10.10.150.20: tcpdump -n host 10.10.150.20. You can also use the regular expression \ delimiters that select whole words.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |