Sponsored Content
Top Forums Shell Programming and Scripting print next line if matches a particular word..need help Post 302204566 by anish19 on Thursday 12th of June 2008 03:14:26 AM
Old 06-12-2008
Java print next line if matches a particular word..need help

Hi
i need a help for making a script whch can print next line if it matches a particular word
like file1 have
ename Mohan
eid 2008
ename Shyam
eid 345

if scipt got Mohan it will print next line (eid 2008)

pls help me .......Smilie
 

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
sysevent_post_event(3SYSEVENT)				  System Event Library Functions			    sysevent_post_event(3SYSEVENT)

NAME
sysevent_post_event - post system event for applications SYNOPSIS
cc [ flag... ] file... -lsysevent -lnvpair [ library... ] #include <libsysevent.h> #include <libnvpair.h> int sysevent_post_event(char *class, char *subclass, char *vendor, char *publisher, nvlist_t *attr_list, sysevent_id_t *eid); PARAMETERS
attr_list pointer to an nvlist_t, listing the name-value attributes associated with the event, or NULL if there are no such attributes for this event class pointer to a string defining the event class eid pointer to a system unique identifier publisher pointer to a string defining the event's publisher nam subclass pointer to a string defining the event subclass vendor pointer to a string defining the vendor DESCRIPTION
The sysevent_post_event() function causes a system event of the specified class, subclass, vendor, and publisher to be generated on behalf of the caller and queued for delivery to the sysevent daemon syseventd(1M). The vendor should be the company stock symbol (or similarly enduring identifier) of the event posting application. The publisher should be the name of the application generating the event. For example, all events posted by Sun applications begin with the company's stock symbol, "SUNW". The publisher is usually the name of the application generating the system event. A system event generated by devfsadm(1M) has a publisher string of devfsadm. The publisher information is used by sysevent consumers to filter unwanted event publishers. Upon successful queuing of the system event, a unique identifier is assigned to eid. RETURN VALUES
The sysevent_post_event() function returns 0 if the system event has been queued successfully for delivery. Otherwise it returns -1 and sets errno to indicate the error. ERRORS
The sysevent_post_event() function will fail if: ENOMEM Insufficient resources to queue the system event. EIO The syseventd daemon is not responding and events cannot be queued or delivered at this time. EINVAL Invalid argument. EPERM Permission denied. EFAULT A copy error occurred. EXAMPLES
Example 1 Post a system event event with no attributes. The following example posts a system event event with no attributes. if (sysevent_post_event(EC_PRIV, "ESC_MYSUBCLASS", "SUNW", argv[0], NULL), &eid == -1) { fprintf(stderr, "error logging system event "); } Example 2 Post a system event with two name-value pair attributes. The following example posts a system event event with two name-value pair attributes, an integer value and a string. nvlist_t *attr_list; uint32_t uint32_val = 0XFFFFFFFF; char *string_val = "string value data"; if (nvlist_alloc(&attr_list, 0, 0) == 0) { err = nvlist_add_uint32(attr_list, "uint32 data", uint32_val); if (err == 0) err = nvlist_add_string(attr_list, "str data", string_val); if (err == 0) err = sysevent_post_event(EC_PRIV, "ESC_MYSUBCLASS", "SUNW", argv[0], attr_list, &eid); if (err != 0) fprintf(stderr, "error logging system event "); nvlist_free(attr_list); } ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Interface Stability |Evolving | +-----------------------------+-----------------------------+ |MT-Level |MT-Safe | +-----------------------------+-----------------------------+ SEE ALSO
devfsadm(1M), syseventd(1M), nvlist_add_boolean(3NVPAIR), nvlist_alloc(3NVPAIR), attributes(5) SunOS 5.11 26 May 2004 sysevent_post_event(3SYSEVENT)
All times are GMT -4. The time now is 03:50 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy