Hi, I am new to linux and have a challenge while I am debugging my application logs n linux boxes.
our log file xxx.log will have different responses coming in its way while an user logs in. Each response might be of 2000 lines or more. Many users do login at a time and our log file goes big and big.
What command or script should I write to take last occurrence of particular response of one user. In the following example what should I do to take last occurrence of response2 of user1 ?
I am not interested in running less command and copy from the screen. could you guys suggest me with a command or script ?
Responses in logs are like below:
Thanks in advance,
Narayana.V
Moderator's Comments:
Please use next time code tags for your code and data
Last edited by vbe; 01-18-2012 at 12:32 PM..
Reason: code tags
I am working on Solaris.
awk --version is not working to get the version.
your awk code ran and given me some random one line output from the log, it has not given me the output that I required. This line is not part of the response also.
Thank You Scrutinizer !
First command is having syntax error.
Second command worked partially as it has not printed the complete response2 of user1 where it missed to have part of response below and also it printed some part of response1 of some other user on top ..
It has given me the output like below
some 100 lines from response1
<response2>
got till
<userId>user1</userId>
-- some lines from response2
-- missed most of the lines here ..
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)