Linux grep Command Extracting Text by Keyword


grep command is used to display matching keyword with their specified files .
Example now in the /etc/passwd file it contain lot of user password and their user name now I like to filter name user2 in these case Linux grep command has been used.
[root@localhost ~]# vim /etc/passwd
[root@localhost ~]# grep 'user2' /etc/passwd

Linux grep it has the various option –i to search case insensitively
grep-n to print the number of matches line
[root@localhost ~]# grep -n 'user2' /etc/passwd
-v print lines not containing patter
-Ax to include the x lines after each match
-Bx to include the x line before each match

No comments:
Write comments