Scrutinizer's solutions are elegant and correct for the input you posted.
What syntax error are you getting from the first command? Awk should tell you where the syntax error is:
Notice the caret ('^') in the last line. It points to the position of syntax error.
Are your responses really separated by an empty line?
Can you please post a sample from your real input? (Use code tags).
Hi, I am searching for a response xml. As you might know xml tags ends with </.
My user tag starts with <user> and ends with </user> but not with <user>.
I believe, We need to use escape patterns for that. Anyway I am trying with
as follows which is working without syntax error but couldnt give me the
the result that I wanted.
For security reasons, I can not paste the sample log from my actual log, but I am pasting the replica of my log with some dummy tags and values in it.
Please check and help me in getting response2 of user1.
I am using correct tags while I am running on actual log, so pls ignore if you find tag used for user is not correct in the following snippet.
Thanks for your continuous effort.
---------- Post updated at 11:05 AM ---------- Previous update was at 10:54 AM ----------
Some points to be noted
. There may be some n number of response1 responses and n number of response2 responses of each user.
So I need the last response2 of user1.
I ran the command
on the code snippet (saved in logForum.txt) given in previous post.
It gives me nothing in the output.
Last edited by nariwithu; 01-20-2012 at 12:06 PM..
Reason: missing end CODE tag
I ran the command
Code:
/usr/xpg4/bin/awk '/<user>user1/&&/response2>/{p=$0}END{print p}' RS= logForum.txt on the code snippet (saved in logForum.txt) given in previous post.
It gives me nothing in the output.
That's because you didn't copy it correctly from Scrutinizer's post:
since your sample input contained <userId> tag but not <user> tag.
The reason why it's not giving you what you want on your real input is because from what i see now, the responses are not separated by empy lines, like you posted before. Try to pre-process the file by inserting an empty line before opening <response[0-9]*> tag and after closing tag:
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:
I tried to run with your sed command on my log, it still didnt give me any response.
Ohh.. How did I do that ? Yes Mirni it is typo error. My sincere apologies for inconvenience.
I modified my template log file with the correct tag .. But it is not replacing the empty lines where it is just displaying n before and after response tags .. Pasted the output below.. I think we should better use escape pattern for that as well ..
Here is the modified log file
Last edited by nariwithu; 01-20-2012 at 03:08 PM..
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)
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)
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)
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)