Sponsored Content
Top Forums Shell Programming and Scripting print next line if matches a particular word..need help Post 302204594 by anish19 on Thursday 12th of June 2008 05:06:24 AM
Old 06-12-2008
Hi

Thanks for ur reply but have little bit doubt

if i have file
ename Mohan
ename2 Mohan
eid 2008
ename Shyam
eid 345

and i will give sed -n -e '/Mohan/ {n; p;}' filename
it wiil give output
ename2 Mohan

here when command finds Mohan it is prinitng next line ename2 Mohan but it should also print eid 2008 as file is also having line ename2 Mohan
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Print line if first Field matches a pattern

Hi All, I would like my code to be able to print out the whole line if 1st field has a dot in the number. Sample input and expected output given below. My AWK code is below but it can;t work, can any expert help me ? Thanks in advance. {if ($1 ~ /*\.*/) { print $0 }} Input: ... (2 Replies)
Discussion started by: Raynon
2 Replies

2. Shell Programming and Scripting

Print word 1 in line 1 and word 2 in line 2 if it matches a pattern

i have a file in this pattern MATCH1 word1 IMAGE word3 word4 MATCH2 word1 word2 word3 word4 MATCH2 word1 word2 word3 word4 MATCH2 word1 word2 word3 word4 MATCH2 word1 word2 word3 word4 MATCH1 word1 IMAGE word3 word4 MATCH2 word1 word2 word3 word4 MATCH2 word1 word2 word3 word4 MATCH2 word1... (7 Replies)
Discussion started by: bangaram
7 Replies

3. Shell Programming and Scripting

How to print line if field matches?

Hi all, I got several lines line this a b c d e 1 e a 1 c d e 3 f a b c 1 e 8 h a b c d e 1 w a 1 c d e 2 w a b c d e 1 t a b c d e 7 4 How can I print the line if 1 is the field one before the last field? Basicly this 2 field ? a b c d e 1 e a b c d e 1 t The file I got is... (7 Replies)
Discussion started by: stinkefisch
7 Replies

4. Shell Programming and Scripting

copy line to new file if word matches

I'm drawing blank on this. The log file I have is filled with garbage, but the important lines are ##/##/### Installation xxxxxxx So, I want to sed the line to a new file IF the word installation is in it. I tried removing none matching lines sed 's/Installation/,//!d' infile > outfile but that... (3 Replies)
Discussion started by: dba_frog
3 Replies

5. UNIX for Advanced & Expert Users

Print line if subsrt matches array

Hi Folks! im printing all lines where the characters in position 270-271 match 33|H1|HA|KA|26 so i came up with this #!/bin/bash array=(33 H1 HA KA 26 ) for i in "${array}" do #echo $i awk '{ if (substr($0,270,2)~'/$i/') print; }' $1 >> $1.temp done It works fine . but... (2 Replies)
Discussion started by: phpsnook
2 Replies

6. Shell Programming and Scripting

Using regex's from file1, print line and line after matches in file2

Good day, I have a list of regular expressions in file1. For each match in file2, print the containing line and the line after. file1: file2: Output: I can match a regex and print the line and line after awk '{lines = $0} /Macrosiphum_rosae/ {print lines ; print lines } ' ... (1 Reply)
Discussion started by: pathunkathunk
1 Replies

7. Shell Programming and Scripting

awk to print the line that matches and the next if line is wrapped

I have a file and when I match the word "initiators" in the first column I need to be able to print the rest of the columns in that row. This is fine for the most part but on occasion the "initiators" line gets wrapped to the next line. Here is a sample of the file. caw-enabled ... (3 Replies)
Discussion started by: kieranfoley
3 Replies

8. Shell Programming and Scripting

How to print line if two lines above it matches patterns.?

Hi, I could only find examples to print line before/after a match, but I'd need to print line after two separate lines matching. E.g.: From the below log entry, I would need to print out the 1234. This is from a huge log file, that has a lot of entries with "CLIENT" and "No" entries (+ other... (3 Replies)
Discussion started by: Juha
3 Replies

9. Linux

Print line 1 if line 3 matches of the output

Hi I want to extend following command so that on the basis of "Branch: ****" on the third line I can grep and print name of the file on the first line. cat .labellog.emd | grep DA2458A7962276A7E040E50A0DC06459 | cut -d " " -f2 | grep -v branch_name | xargs -I file <command to describe> file ... (1 Reply)
Discussion started by: ezee
1 Replies

10. Shell Programming and Scripting

Print whole line if variables matches

Der colleagues, 4 days I am trying to solve my issue and no success.. Maybe you can give me a clue how to achieve what I need.. So I have two files. file1 example: 1_column1.1 1_column2.1 aaa 1_column4.1 1_column1.2 1_column2.2 ttt 1_column4.2 1_column1.3 1_column2.3 ... (10 Replies)
Discussion started by: nypreH
10 Replies
bss::doc::pod3::bss(3)					       BSS library functions					    bss::doc::pod3::bss(3)

NAME
bss - Bundle Streaming Service library SYNOPSIS
#include "bss.h" typedef int (*RTBHandler)(time_t time, unsigned long count, char *buffer, int bufLength); [see description for available functions] DESCRIPTION
The BSS library supports the streaming of data over delay-tolerant networking (DTN) bundles. The intent of the library is to enable applications that pass streaming data received in transmission time order (i.e., without time regressions) to an application-specific "display" function -- notionally for immediate real-time display -- but to store all received data (including out-of-order data) in a private database for playback under user control. The reception and real-time display of in-order data is performed by a background thread, leaving the application's main (foreground) thread free to respond to user commands controlling playback or other application- specific functions. The application-specific "display" function invoked by the background thread must conform to the RTBHandler type definition. It must return 0 on success, -1 on any error that should terminate the background thread. Only on return from this function will the background thread proceed to acquire the next BSS payload. All data acquired by the BSS background thread is written to a BSS database comprising three files: table, list, and data. The name of the database is the root name that is common to the three files, e.g., db3.tbl, db3.lst, db3.dat would be the three files making up the db3 BSS database. All three files of the selected BSS database must reside in the same directory of the file system. Several replay navigation functions in the BSS library require that the application provide a navigation state structure of type bssNav as defined in the bss.h header file. The application is not reponsible for populating this structure; it's strictly for the private use of the BSS library. int bssOpen(char *bssName, char *path, char *eid) Opens access to a BSS database, to enable data playback. bssName identifies the specific BSS database that is to be opened. path identifies the directory in which the database resides. eid is ignored. On any failure, returns -1. On success, returns zero. int bssStart(char *bssName, char *path, char *eid, char *buffer, int bufLen, RTBHandler handler) Starts a BSS data acquisition background thread. bssName identifies the BSS database into which data will be acquired. path identifies the directory in which that database resides. eid is used to open the BP endpoint at which the delivered BSS bundle payload contents will be acquired. buffer identifies a data acquisition buffer, which must be provided by the application, and bufLen indicates the length of that buffer; received bundle payloads in excess of this length will be discarded. handler identifies the display function to which each in-order bundle payload will be passed. On any failure, returns -1. On success, returns zero. int bssRun(char *bssName, char *path, char *eid, char *buffer, int bufLen, RTBHandler handler) A convenience function that performs both bssOpen() and bssStart(). On any failure, returns -1. On success, returns zero. void bssClose() Terminates data playback access to the most recently opened BSS database. void bssStop() Terminates the most recently initiated BSS data acquisition background thread. void bssExit() A convenience function that performs both bssClose() and bssStop(). long bssRead(bssNav nav, char *data, int dataLen) Copies the data at the current playback position in the database, as indicated by nav, into data; if the length of the data is in excess of dataLen then an error condition is asserted (i.e., -1 is returned). Note that bssRead() cannot be successfully called until nav has been populated, nominally by a preceding call to bssSeek(), bssNext(), or bssPrev(). Returns the length of data read, or -1 on any error. long bssSeek(bssNav *nav, time_t time, time_t *curTime, unsigned long *count) Sets the current playback position in the database, in nav, to the data received in the bundle with the earliest creation time that was greater than or equal to time. Populates nav and also returns the creation time and bundle ID count of that bundle in curTime and count. Returns the length of data at this location, or -1 on any error. long bssSeek_read(bssNav *nav, time_t time, time_t *curTime, unsigned long *count, char *data, int dataLen) A convenience function that performs bssSeek() followed by an immediate bssRead() to return the data at the new playback position. Returns the length of data read, or -1 on any error. long bssNext(bssNav *nav, time_t *curTime, unsigned long *count) Sets the playback position in the database, in nav, to the data received in the bundle with the earliest creation time and ID count greater than that of the bundle at the current playback position. Populates nav and also returns the creation time and bundle ID count of that bundle in curTime and count. Returns the length of data at this location (if any), -2 on reaching end of list, or -1 on any error. long bssNext_read(bssNav *nav, time_t *curTime, unsigned long *count, char *data, int dataLen) A convenience function that performs bssNext() followed by an immediate bssRead() to return the data at the new playback position. Returns the length of data read, -2 on reaching end of list, or -1 on any error. long bssPrev(bssNav *nav, time_t *curTime, unsigned long *count) Sets the playback position in the database, in nav, to the data received in the bundle with the latest creation time and ID count earlier than that of the bundle at the current playback position. Populates nav and also returns the creation time and bundle ID count of that bundle in curTime and count. Returns the length of data at this location (if any), -2 on reaching end of list, or -1 on any error. long bssPrev_read(bssNav *nav, time_t *curTime, unsigned long *count, char *data, int dataLen) A convenience function that performs bssPrev() followed by an immediate bssRead() to return the data at the new playback position. Returns the length of data read, -2 on reaching end of list, or -1 on any error. SEE ALSO
bp(3) perl v5.14.2 2012-05-25 bss::doc::pod3::bss(3)
All times are GMT -4. The time now is 11:12 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy