Sponsored Content
Top Forums Shell Programming and Scripting Last occurrence of code between two tags Post 302591737 by nariwithu on Friday 20th of January 2012 11:58:54 AM
Old 01-20-2012
Quote:
Originally Posted by mirni
That's because you didn't copy it correctly from Scrutinizer's post:
I have used correct tags while I ran the commands. Yes I agree, I had given one time as userId and now I am using user. I had given a note on this in my previous post.

Quote:
Code:
sed -e 's/.*<response[0-9]*>.*/\n&/; s/<\/response[0-9]*>/&\n/' inputFile |  /usr/xpg4/bin/awk '/<user>user1<\/user>/&&/response2/{p=$0}END{print p}' RS=

I tried to run with your sed command on my log, it still didnt give me any response.

My log now has <user> tag, but not <userId> tag..

Sorry for confusion.
 

5 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Replace second occurrence only

HPUX /bin/sh (posix) I have a file as such cat dog mouse deer elk rabbit mouse rat pig I would like to replace the second occurrence of mouse in this file with mouse2. The rest of the file has to stay exactly as is. I'm not sure exactly where mouse might be (could be first,second,third... (5 Replies)
Discussion started by: lyoncc
5 Replies

2. Shell Programming and Scripting

number of occurrence

: i need a bash script to convert the displayed output 12 14 15 12 15 13 to 12 * 2 ,13 * 1,14*1,15*1 Thanks, nevil (2 Replies)
Discussion started by: nevil
2 Replies

3. Shell Programming and Scripting

Substitute first occurrence of keyword if occurrence between two other keywords

Assume a string that contains one or multiple occurrences of three different keywords (abbreviated as "kw"). I would like to replace kw2 with some other string, say "qux". Specifically, I would like to replace that occurrence of kw2 that is the first one that is preceded by kw1 somewhere in the... (4 Replies)
Discussion started by: M Gruenstaeudl
4 Replies

4. UNIX for Dummies Questions & Answers

Code for exact match to count occurrence

Hi all, I have an input file as below. I would like to count the occurrence of pattern matching 8th field for each line. Input: field_01 field_02 field_03 field_04 field_05 field_06 field_07 field_08 TA T TA T TA TA TA... (3 Replies)
Discussion started by: huiyee1
3 Replies

5. Shell Programming and Scripting

sed print from last occurrence match until the end of last occurrence match

Hi, i have file file.txt with data like: START 03:11:30 a 03:11:40 b END START 03:13:30 eee 03:13:35 fff END jjjjjjjjjjjjjjjjjjjjj START 03:14:30 eee 03:15:30 fff END ggggggggggg iiiiiiiiiiiiiiiiiiiiiiiii I want the below output START (13 Replies)
Discussion started by: Jyotshna
13 Replies
All times are GMT -4. The time now is 02:27 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy