Linux grepThe 'grep' command stands for "global regular expression print". grep command filters the content of a file which makes our search easy. grep with pipe The 'grep' command is generally used with pipe (|). Syntax: Example: Look at the above snapshot, grep command filters all the data containing '9'. grep without pipeIt can be used without pipe also. Syntax: Example: Look at the above snapshot, grep command do the same work as earlier example but without pipe. grep options
Syntax: Example: Look at the above snapshot, command "grep -v 9 marks.txt" displays lines hwich don't contain our search word '9'. Syntax: Example: Look at the above snapshot, command "grep -i red exm.txt" displays all lines containing 'red' whether in upper case or lower case. Syntax: Example: Look at the above snapshot, command "grep -A1 yellow exm.txt" displays searched line with next succeeding line, command "grep -B1 yellow exm.txt" displays searched line with one preceding line and command "grep -C1 yellow exm.txt" displays searched line with one preceding and succeeding line. Next TopicLinux comm
|