Sponsored Content
Top Forums Shell Programming and Scripting Grep three consecutive lines if each lines contains certain string Post 302960741 by Saumitra Pandey on Thursday 19th of November 2015 06:09:41 AM
Old 11-19-2015
Quote:
Originally Posted by RudiC
That is a very vague description. Please be way more detailed and specific. Why should we select 2914 | REQUEST and not 2986 | REQUEST? Your code snippet would print a "REQUEST" line and the very next "RESPONSE" line coming up, independent of contents.
I want to print a pattern with request, response and success in order. Whenever they are together it should print and skip all others.

like the below pattern irrespective of the number given in beginning:
Code:
2914 | REQUEST | whatever
2914 | RESPONSE | whatever
2914 | SUCCESS | whatever


Last edited by Scrutinizer; 11-20-2015 at 05:06 AM..
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

grep string & next n lines

need help on this. let say i hv 1 file contains as below: STRING Description bla bla bla Description yada yada yada Data bla bla Data yada yada how do i want to display n lines after the string? thanks in advance! (8 Replies)
Discussion started by: ashterix
8 Replies

2. Shell Programming and Scripting

Like grep -v for a string over 2 lines? Sed?

Hi, I have a log file that I need to monitor as it's being written to, and I want to exclude certain strings from the output. At the moment I'm using ... tail -f LogFileName_`date +%d`.log | egrep -v "First String To Exclude | 2nd string | 3rd string" ...which works OK - but now I need to... (1 Reply)
Discussion started by: jake657
1 Replies

3. Shell Programming and Scripting

Print lines between two lines after grep for a text string

I have several very large file that are extracts from Oracle tables. These files are formatted in XML type syntax with multiple entries like: <ROW> some information more information </ROW> I want to grep for some words, then print all lines between <ROW> AND </ROW>. Can this be done with AWK?... (7 Replies)
Discussion started by: jbruce
7 Replies

4. Shell Programming and Scripting

Merge two non-consecutive lines based on line number or string

This is a variation of an earlier post found here: unixcom/shell-programming-scripting/159821-merge-two-non-consecutive-lines.html User Bartus11 was kind enough to solve that example. Previously, I needed help combining two lines that are non-consecutive in a file. Now I need to do the... (7 Replies)
Discussion started by: munkee
7 Replies

5. Shell Programming and Scripting

Grep a string from input file and delete next three lines including the line contains string in xml

Hi, 1_strings file contains $ cat 1_strings /home/$USER/Src /home/Valid /home/Review$ cat myxml <projected value="some string" path="/home/$USER/Src"> <input 1/> <estimate value/> <somestring/> </projected> <few more lines > <projected value="some string" path="/home/$USER/check">... (4 Replies)
Discussion started by: greet_sed
4 Replies

6. Shell Programming and Scripting

aix :grep to get lines before and after string

am using AIX and I have a string "There is no process to read data written to a pipe". I want to get the output 2 lines before and 4 lines after this string. The string is present like more than 100 times in the log and I want to output, the last result in the log with this string I tried using... (1 Reply)
Discussion started by: PhAnT0M
1 Replies

7. Shell Programming and Scripting

Grep couple of consecutive lines if each lines contains certain string

Hello, I want to extract from a file like : 20120530025502914 | REQUEST | whatever 20120530025502968 | RESPONSE | whatever 20120530025502985 | RESPONSE | whatever 20120530025502996 | REQUEST | whatever 20120530025503013 | REQUEST | whatever 20120530025503045 | RESPONSE | whatever I want... (14 Replies)
Discussion started by: black_fender
14 Replies

8. Shell Programming and Scripting

Grep 2 consecutive lines and replace the second line in a file

I have a file lake this cat ex1.txt </DISCOUNTS> <B2B_SPECIFICATION elem="0"> <B2B_SPECIFICATION elem="0"> <DESCR>Netti 2 </DESCR> <NUMBER>D02021507505</NUMBER> </B2B_SPECIFICATION> <B2B_SPECIFICATION elem="1"> <DESCR>Puhepaketti</DESCR>... (2 Replies)
Discussion started by: Dhoni
2 Replies

9. Shell Programming and Scripting

Grep a string and count following lines starting with another string

I have a large dataset with following structure; C 0001 Carbon D SAR001 methane D SAR002 ethane D SAR003 propane D SAR004 butane D SAR005 pentane C 0002 Hydrogen C 0003 Nitrogen C 0004 Oxygen D SAR011 ozone D SAR012 super oxide C 0005 Sulphur D SAR013... (3 Replies)
Discussion started by: Syeda Sumayya
3 Replies

10. Shell Programming and Scripting

Remove duplicate consecutive lines with specific string

Hello, I'm trying to remove the duplicate consecutive lines with specific string "WARNING". File.txt abc; WARNING 2345 WARNING 2345 WARNING 2345 WARNING 2345 WARNING 2345 bcd; abc; 123 123 123 WARNING 1234 WARNING 2345 WARNING 2345 efgh; (6 Replies)
Discussion started by: Mannu2525
6 Replies
ripquery(8)						      System Manager's Manual						       ripquery(8)

NAME
ripquery - Queries RIP gateways SYNOPSIS
/usr/sbin/ripquery [-1] [-2] [-[a5] authkey] [-n] [-p] [-r] [-v] [-w time] gateway ... FLAGS
Sends the query as a version 1 packet. Sends the query as a version 2 packet (default). Specifies the authentication password to use for queries. If -a specified, an authentication type of SIMPLE will be used, if -5 is specified, an authentication type of MD5 will be used, otherwise the default is an authentication type of NONE. Authentication fields in incoming packets will be displayed, but not validated. Prevents the address of the responding host from being looked up to determine the symbolic name. Uses the RIP POLL command to request information from the routing table. This is the default. If there is no response to the RIP POLL command, the RIP REQUEST command is tried. The gated daemon responds to a POLL command with all the routes learned through RIP. Used the RIP REQUEST command to request information from the gateway's routing table. Unlike the RIP POLL command, all gateways should support the RIP REQUEST. If there is no response to the RIP REQUEST command, the RIP POLL command is tried. The gated daemon responds to a REQUEST command with all the routes he announces out the specified interface. Because of limitations in the UDP interface, on systems based on BSD 4.3 Reno or earlier, REQUESTs respond about the interface used to route packets back to the sender. This can be avoided by running ripquery on the host being queried. Displays version information about ripquery before querying the gateways. Specifies the time in seconds to wait for the initial response from a gateway. The default value is 5 seconds. DESCRIPTION
The ripquery command is used to request all routes known by a RIP gateway by sending a RIP request or POLL command. The routing informa- tion in any routing packets returned is displayed numerically and symbolically. The ripquery command is intended to be used as a tool for debugging gateways, not for network management. SNMP is the preferred protocol for network management. The ripquery command by default uses the RIP POLL command, which is an undocumented extension to the RIP specification supported by routed on SunOS 3.x and later and by gated 1.4 and later. The RIP POLL command is preferred over the RIP REQUEST command because it is not sub- ject to Split Horizon or Poisoned Reverse. See the RIP RFC for more information. RELATED INFORMATION
Commands: gated(8), gdc(8), ospf_monitor(8), routed(8) delim off ripquery(8)
All times are GMT -4. The time now is 04:41 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy