Sponsored Content
Top Forums Shell Programming and Scripting grep the line only if next line matches Post 302124203 by pbsrinivas on Friday 29th of June 2007 05:47:28 AM
Old 06-29-2007
Thanks anbu aigles
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Appending Text To Each Line That Matches Grep

I'm currently digging for a way to append a line to a text file where each line begins with the word "setmqaut". This is a continuation of my IBM MQSeries backup script I'm working on to make my life a little easier. What I would like to do is have each line that looks like this: setmqaut -m... (4 Replies)
Discussion started by: sysera
4 Replies

2. UNIX for Advanced & Expert Users

Inserting a line before the line which matches the patter

Hi Is there any command where we can insert a line "2|||" before every line starting with "3|" my input is as follows 1|ETG|12345 3|79.58|||GBP|| 1|ETG|12345 3|79.58|||GBP|| 1|ETG|12345 2|EN_GB||Electrogalvanize 0.5 m2 ( Renault ) 1|ETG|12345 3|88.51|||GBP|| desired output... (10 Replies)
Discussion started by: laxmi131
10 Replies

3. Shell Programming and Scripting

cat file1 read line-per-line then grep -A 15 lines down in fileb

STEP 1 # Set variable FILE=/tmp/mainfile SEARCHFILE =/tmp/searchfile # THIS IS THE MAIN FILE. cat /tmp/mainfile Interface Ethernet0/0 "outside", is up, line protocol is up Hardware is i82546GB rev03, BW 100 Mbps Full-Duplex(Full-duplex), 100 Mbps(100 Mbps) MAC address... (6 Replies)
Discussion started by: irongeekio
6 Replies

4. 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

5. UNIX for Dummies Questions & Answers

if line matches then

I have a file that I need to read each line and see if the line begins with a certain keyword. I can't seem to find something that works. #!/bin/ksh # while read i do if ] then echo "SE2 WORKS" elif ] then echo "CISCO1 WORKS" fi done < tmp/diff The file looks something like SE1 SE2... (2 Replies)
Discussion started by: numele
2 Replies

6. Shell Programming and Scripting

How to substitute a line that matches an expression with another line

I need some help. I have a file (all.txt) whereby I want to substitute using sed/awk all lines that matches an expression with another line with different expression i.e subtitute expression, database_id: filename; WITH database_id: PY; There are many occurrences of the expression... (4 Replies)
Discussion started by: aimsoft
4 Replies

7. UNIX for Dummies Questions & Answers

print line that matches and next line, too

I'm using sh on hp-ux and want to find / print a line that matches 132.101- and the next line, too. grep -A isn't supported on hp-ux, so I'm trying awk and sed. The code below works but only prints the first occurence. I need all matches from the file. awk... (2 Replies)
Discussion started by: Scottie1954
2 Replies

8. 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

9. 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

10. 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
TAU_PROFILE_SET_CONT(3) 				      TAU Instrumentation API					   TAU_PROFILE_SET_CONT(3)

NAME
TAU_PROFILE_SET_CONTEXT - Informs the measurement system of the context id SYNOPSIS
C/C++: TAU_PROFILE_SET_CONTEXT(int context); Fortran: TAU_PROFILE_SET_CONTEXT(integer context); DESCRIPTION
The TAU_PROFILE_SET_CONTEXT macro sets the context identifier of the executing task for profiling and tracing. Tasks are identified using context, context and thread ids. The profile data files generated will accordingly be named profile.<context>.<context>.<thread>. Note that it is not necessary to call TAU_PROFILE_SET_CONTEXT when using the TAU MPI wrapper library. EXAMPLE
C/C++ : int main (int argc, char **argv) { int ret, i; pthread_attr_t attr; pthread_t tid; TAU_PROFILE_TIMER(tautimer,"main()", "int (int, char **)", TAU_DEFAULT); TAU_PROFILE_START(tautimer); TAU_PROFILE_INIT(argc, argv); TAU_PROFILE_SET_NODE(0); TAU_PROFILE_SET_CONTEXT(1); /* ... */ TAU_PROFILE_STOP(tautimer); return 0; } Fortran : PROGRAM SUM_OF_CUBES integer profiler(2) / 0, 0 / save profiler INTEGER :: H, T, U call TAU_PROFILE_INIT() call TAU_PROFILE_TIMER(profiler, 'PROGRAM SUM_OF_CUBES') call TAU_PROFILE_START(profiler) call TAU_PROFILE_SET_NODE(0) call TAU_PROFILE_SET_CONTEXT(1) ! This program prints all 3-digit numbers that ! equal the sum of the cubes of their digits. DO H = 1, 9 DO T = 0, 9 DO U = 0, 9 IF (100*H + 10*T + U == H**3 + T**3 + U**3) THEN PRINT "(3I1)", H, T, U ENDIF END DO END DO END DO call TAU_PROFILE_STOP(profiler) END PROGRAM SUM_OF_CUBES SEE ALSO
TAU_PROFILE_SET_NODE(3) 08/31/2005 TAU_PROFILE_SET_CONT(3)
All times are GMT -4. The time now is 06:29 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy