Sponsored Content
Top Forums Shell Programming and Scripting Print lines between two lines after grep for a text string Post 302458075 by jbruce on Wednesday 29th of September 2010 02:22:54 PM
Old 09-29-2010
Print lines between two lines after grep for a text string

Franklin, Thank you for the time you have taken to answer my query. The latest code works and produces the output that I wanted, however it will stop at the first occurrence of the <pattern>. In the file I am using for my test there are 19 of the key words.
 

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Print lines after grep

Hi all, I need help in following scenario. I have a file with about 10,000 lines. There are several lines which have word "START" (all upper case) in them. I want to grep line with word "START" and then do the following 1. Print the line number having word "START" 2. Print the next 11 lines. ... (4 Replies)
Discussion started by: jakSun8
4 Replies

2. Shell Programming and Scripting

print only matched string instead lines in grep

frnd, Is there any way to print only the string that matched the pattern instead printing the whole line? thanks in advance. (3 Replies)
Discussion started by: clx
3 Replies

3. Shell Programming and Scripting

AIX equivalent to GNU grep's -B and -A [print lines after or before matching lines]

Hi folks I am not allowed to install GNU grep on AIX. Here my code excerpt: grep_fatal () { /usr/sfw/bin/gegrep -B4 -A2 "FATAL|QUEUE|SIGHUP" } Howto the same on AIX based machine? from manual GNU grep ‘--after-context=num’ Print num lines of trailing context after... (4 Replies)
Discussion started by: slashdotweenie
4 Replies

4. Shell Programming and Scripting

print string at the end of lines in text file

hello, I go text file like this E:/DDD/Dyndede/wwww E:/DDD/sss.com/ffffg/fff E:/DDD/vvvvvv/dd E:/DDD/sss.com/bbbbbb E:/DDD/sss.com/nnnn/xxI want to print /alpha.jpg at the end of every lines like that E:/DDD/Dyndede/wwww/alpha.jpg E:/DDD/sss.com/ffffg/fff/alpha.jpg... (8 Replies)
Discussion started by: davidkhan
8 Replies

5. Shell Programming and Scripting

print lines AFTER lines cointaining a regexp (or print every first and fourth line)

Hi all, This should be very easy but I can't figure it out... I have a file that looks like this: @SRR057408.1 FW8Y5CK02R652T length=34 AGCAGTGGTATCAACGCAGAGTAAGCAGTGGTAT +SRR057408.1 FW8Y5CK02R652T length=34 FIIHFF6666?=:88@@@BBD:::?@ABBAAA>8 @SRR057408.2 FW8Y5CK02TBMHV length=52... (1 Reply)
Discussion started by: kmkocot
1 Replies

6. Shell Programming and Scripting

Print lines before and after..not grep -A

Hi I have this in my file 2011-04-18 15:32:11 system-alert-00012: UDP flood! From xxxxxx to yyyyyyyyyy, int ethernet0/2). Occurred 1 times. 2011-04-18 15:32:11 system-alert-00012: UDP flood! From xxxxxx to yyyyyyyyyy, int ethernet0/2). Occurred 1 times. 2011-04-18 15:32:11... (9 Replies)
Discussion started by: zorrox
9 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 for the string and then print the next 4 lines

RHEL 5.8 I have a text file like below. I want to grep for a string and then print the next 4 lines including the line with the string I grepped for For eg: I want grep for the string HANS and then print the next 4 lines including HANS $ cat someText.txt JOHN NATIONALITY:... (7 Replies)
Discussion started by: omega3
7 Replies

9. Shell Programming and Scripting

Grep three consecutive lines if each lines contains certain string

say we have : 2914 | REQUEST | whatever 2914 | RESPONSE | whatever 2914 | SUCCESS | whatever 2985 | RESPONSE | whatever 2986 | REQUEST | whatever 2990 | REQUEST | whatever 2985 | RESPONSE | whatever 2996 | REQUEST | whatever 2010 | SUCCESS | whatever 2013 | REQUEST | whatever 2013 |... (7 Replies)
Discussion started by: Saumitra Pandey
7 Replies
UPSCLI_LIST_NEXT(3)						    NUT Manual						       UPSCLI_LIST_NEXT(3)

NAME
upscli_list_next - retrieve list items from a UPS SYNOPSIS
#include <upsclient.h> int upscli_list_next(UPSCONN_t *ups, int numq, const char **query, int *numa, char ***answer) DESCRIPTION
The upscli_list_next() function takes the pointer ups to a UPSCONN_t state structure, and the pointer query to an array of numq query elements. It performs a read from the network and expects to find either another list item or the end of a list. You must call upscli_list_start(3) before calling this function. This function will return 1 and set values in numa and answer if a list item is received. If the list is done, it will return 0, and the values in numa and answer are undefined. Calling this function after it returns something other than 1 is undefined. QUERY FORMATTING
You may not change the values of numq or query between the call to upscli_list_start(3) and the first call to this function. You also may not change the values between calls to this function. ANSWER FORMATTING
The contents of numa and answer work just like a call to upscli_get(3). The values returned by upsd(8) are identical to a single item request, so this is not surprising. ERROR CHECKING
This function checks the response from upsd(8) against your query. If the response is not part of the list you have requested, it will return an error code. When this happens, upscli_upserror(3) will return UPSCLI_ERR_PROTOCOL. RETURN VALUE
The upscli_list_next() function returns 1 when list data is present, 0 if the list is finished, or -1 if an error occurs. It is possible to have an empty list. The function will return 0 for its first call in that case. SEE ALSO
upscli_list_start(3), upscli_strerror(3), upscli_upserror(3) Network UPS Tools 05/22/2012 UPSCLI_LIST_NEXT(3)
All times are GMT -4. The time now is 02:44 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy