In this example we are trying to search everything but cyberithub word using grep -v cyberithub file1.txt command as shown below. If you want to invert a word matching then you need to use -v option with grep command. Example 4: Invert Search Pattern using grep command V : Print the version number of grep to the standard output stream. There is NO WARRANTY, to the extent permitted by law. This is free software: you are free to change and redistribute it. License GPLv3+: GNU GPL version 3 or later. ~]# grep -V grep (GNU grep) 2.20Ĭopyright (C) 2014 Free Software Foundation, Inc. As you can see from below output grep command version is 2.20. If you want to check the grep command version then you need to use -V option as shown below. i : Ignore case distinctions in both the PATTERN and the input files. You might want to check 26 Useful Firewall CMD Examples on RedHat/CentOS 7 ~]# grep -i cyberithub file1.txt This is cyberithub Now if you want to remove case sensitivity then you need to use -i option with grep command as mentioned in the below output. You might be interested in 11 Best Linux route command examples (How to add route in Linux) ~]# grep cyberithub file1.txt This is cyberithubĪdvertisements ~]# cat file1.txt This is cyberithub We will try to search a word cyberithub from file1.txt file using grep cyberithub file1.txt command as shown below. Let's say we have an example file file1.txt which has two lines and we want to search some word/string from this file. Grep Īlso Read: 10 Useful iproute2 tools examples to Manage Network Connections in Linux Example 1: How to use grep command in Linux/Unix Here, we will go through different examples of grep command to understand its usages. Another important use of grep command which you will often see is in Linux Scripting. This tool also provides us the capability to do search based on Regular Expressions which makes it further useful in analyzing logs and files for troubleshooting purposes. It is one of the best searching tool currently in use. grep is an open source tool that can be used for searching text/word/strings from files and directories in Linux and Unix based Operating Systems. In this article, I will take you through 31 Useful grep command examples in Linux/Unix. Example 31: Check Other grep command options.Example 30: Exclude Directory from grep command search.Example 29: Exclude Some Files from grep search.Example 28: Stop Displaying output after a MAX Count.Example 27: Suppressing File Name Prefix in the output.Example 26: Using Egrep option with grep command.Example 25: Using grep command in Quiet Mode.Example 24: Include Symlinks in grep command search.Example 23: Redirect grep command output to a file.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |