Webterm shell sh ru grep -u H.H.H tail 10 The -u flag will show all of the lines above the mac address you're searching and then the tail command will just show the last ten lines of … WebThe answer is to use the g lobal command, and also to use the -s flag to suppress any output from ex: ex -sc 'g/address [ [:space:]] [ [:space:]]*172\.29\.16\.103/ ? {?,/}/d x' input This isn't quite equivalent to the earlier command; if there is more than one curly brace block with a matching line, the global command here will delete them all.
SED : Delete 4 line above and below 5 line after pattern match
WebThe simplest way to solve it using grep only, is to pipe one more inverted grep at the end. For example: grep -A 4 "The mail system" temp.txt grep -v "The mail system" grep -v … WebTo look for all available options for the grep command, we can type grep --help (or man grep ). Looks like the -B and -A arguments for grep will be useful to return the matched line plus one before ( -B 1) and two lines after ( -A 2 ). Since each record is four lines, using these arguments will return the whole record. mauveworx limited
How to grep for lines above and below a certain pattern
WebJul 2, 2015 · .+$ {A} - to 2 lines below this one (see :he cmdline-ranges for these two) d - delete the lines. +w !tee then writes to standard output. +q! quits without saving changes. You can skip the variables and use the pattern and numbers directly. I used them just for clarity of purpose. Share Improve this answer answered Jul 1, 2015 at 19:44 muru WebViewed 13k times 2 I want to match for example: The string e1000g0 from the lltconfig -a list , and then to display the two lines after the string e1000g0 so I get only the lines: Node 0 du1a : 00:21:28:14:76:68 Node 1 du1b : 00:21:28:59:72:C4 permanent please advice how the get only the two lines after? full example from ( lltconfig -a list ): WebNov 1, 2010 · i would like to get the above and below lines of the grep pattern . For ex : file as below: chk1- aaaa 1-Nov chk2 -aaaa ##### chk1-bbbbbb 1-Nov chk2-bbbbbb ##### my search pattern is date : 1-Nov i need the o/p as below chk1- aaaa 1-Nov chk2 -aaaa chk1-bbbbbb 1-Nov chk2-bbbbbb Thanks in Advance mauveworx ferndown