Getting tips on using your Linux can be not only interesting but useful for people who frequently use Linux.
One of the most popular commands to use in Unix s grep. Once you learn how to use grep, you will notice it become apart of your pattern commands. When putting together complex commands you will definitely utilize the grep command when it comes to executing at the shell prompt.
Grep means, “Global regular expression printer.” Grep is made to extract lines from given text that matches conditions by the user. You as the user will basically be allowed to enter a pattern of text, which in turn searches for the pattern inside the text that you provided. You will be given all of the lines that have the given pattern in them. The wonderful thing about grep is that you can use it wither by itself or along with pipes. As Linux user you should definitely know about pipes and how to use it.
There are a ton of different commands to use when using grep. Some of the more simple ones are
-v
This command reverses the regular behavior of the grep command . Rather than selecting lines, it will reject the lines that match the chosen criteria.
-c
The thing about this command is that It will suppress the basic output and only prints the complete count of lines that match instead of the actual lines.
-i
This command will Ignore the case of the text when attempting to match the given pattern.
-w
One of the more interesting commands is the -w. It will check if the given pattern is either a word by itself and or a single word.
-l
The -l command will only give the names of the files the given pattern was found in.
-r
You will be able to check for the given pattern ,which in turn checks within the directory that you pinpoint and specify after the -r option.