![linux find file recursive linux find file recursive](https://linuxhint.com/wp-content/uploads/2019/07/17-14-810x475.png)
To display the lines that do not match a pattern, use the -v ( or -invert-match) option.įor example, to print the lines that do not contain the string nologin you would use: grep -v nologin /etc/passwd root:x:0:0:root:/root:/bin/bashĬolord:x:124:124::/var/lib/colord:/bin/false
![linux find file recursive linux find file recursive](https://www.doowebs.eu/wp-content/uploads/2016/08/linux-1024x536.jpg)
If the string includes spaces, you need to enclose it in single or double quotation marks: grep "Gnome Display Manager" /etc/passwd Invert Match (Exclude) #
![linux find file recursive linux find file recursive](https://www.poftut.com/wp-content/uploads/2019/09/img_5d79b9463d205.png)
The output should look something like this: root:x:0:0:root:/root:/bin/bash The most basic usage of the grep command is to search for a string (text) in a file.įor example, to display all the lines containing the string bash from the /etc/passwdįile, you would run the following command: grep bash /etc/passwd To be able to search the file, the user running the command must have read access to the file. The items in square brackets are optional.