shell scripting and programmming

hi
i have to grep a certain pattern
like i have

revision 1.15
date 2011-01-20 author : dpriyank
---------------------------------------
revision 1.10
date 2011-01-10 author : sandeepk
----------------------------------------
revision 1.2
date 2011-01-09 author : tanvi
----------------------------------------
revision 1.1
date 2011-01-02 auhtor : jatin

i just need revision 1.1 and the author name.....what should i do

i tried

grep -o -e "revision 1.1" -e "author" | awk '{print $3}'

it is giving the answer

revision 1.1 dpriyank
revision 1.1 sandeepk
revision 1.1 jatin

i only want the revison 1.1 and the name of the concernd author
plzzz help

grep "\b1.1\b" txt -A1 | tr '\n' ' ' | sed 's/date.*://'
 $ ruby -ne 'print gets.split(":")[-1] if /revision 1.1$/' file  

through sed..

 sed -n '/revision 1.1$/N;s/\n.*:/:/p' inputfile > outfile

revision 1.4
date: 2010-08-15 06:52:24 +0000; author: sandeepk; state: Exp; lines: +1 -1
fixed testcase
----------------------------
revision 1.3
date: 2010-08-15 05:36:28 +0000; author: sandeepk; state: Exp; lines: +2 -0
updated execlevel
----------------------------
revision 1.2
date: 2010-08-15 05:25:02 +0000; author: sandeepk; state: Exp; lines: +15 -3
use name mapping flow
----------------------------
revision 1.1
date: 2010-08-10 10:41:36 +0000; author: sandeepk; state: Exp;
initial check in

revision 1.4
date: 2006-10-31 09:55:13 +0000; author: vkadam; state: Exp; lines: +5 -5
updated
----------------------------
revision 1.3
date: 2006-10-31 08:58:52 +0000; author: vkadam; state: Exp; lines: +1 -1
updated
----------------------------
revision 1.2
date: 2006-10-26 06:19:04 +0000; author: jsaikia; state: Exp; lines: +3 -3
changed exec level to 7.
----------------------------
revision 1.1
date: 2006-10-23 11:24:13 +0000; author: jsaikia; state: Exp;
Testcase on DC block with non-scan design.
----------------------------[/CODE]

i still could not get....this is the actual text from which i want
final answer to be

revision 1.1      author:jsaikia
      revision 1.1      author : sandeepk 

this way i have 50 files to edit......i am just taking an example of 2 ...what shud i do for 50 cases like this

Since your recent post's input file is different from the original one you get like that..You could try the below, formatted according to the post#5's input file

sed -n '/revision 1.1$/N;s/\(.*\)\n.*\(auth.*\); .*/\1 \2/p' inputfile > outfile
1 Like

a more complicated code:

grep "\b1.1\b" infile -A1 | tr '\n' ' ' | sed -e 's/date.*\(author:.*;\)/\1/' | awk 'BEGIN{FS="[ ;:]"}{print $1,$2,$3":"$5}'

Does this works?

awk '/revision 1.1$/{r=$0;getline;gsub(/.*author:|;.*/,"");print r,$0}' file

try:

awk  '$2=="1.1"{printf $0" ";getline;{for (i=1;i<=NF;i++) {if($i~"author"){print $(i+1)}}}}' urfile

or:

sed  -n '/revision 1.1/,+1{N;s/\(.*\)\n\(.*author: \)\(.*\); \(.*\)/\1 \3/;P}' urfile
awk -F";" '/revision 1.1/{s=$0; getline; print s, $2}' file

hi iworked with this command and it worked....but i want to know the functioning of the whole process as the way how u had proceeded?????
thanks for the code

---------- Post updated at 04:02 AM ---------- Previous update was at 03:59 AM ----------

thanks for the code....but i want to know the exact functioning of the whole command which u had send.....i had tried with the backslashes.....