Home Man
Search
Today's Posts
Register

BSD, Linux, and UNIX shell scripting — Post awk, bash, csh, ksh, perl, php, python, sed, sh, shell scripts, and other shell scripting languages questions here.

shell scripting and programmming

Tags
shell scripts

Login to Reply

 
Thread Tools Search this Thread
# 1  
Old 02-02-2011
shell scripting and programmming

hi
i have to grep a certain pattern
like i have
Code:
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
Code:
grep -o -e "revision 1.1" -e "author" | awk '{print $3}'

it is giving the answer
Code:
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

Last edited by Franklin52; 02-02-2011 at 02:46 AM.. Reason: Please use code tags, thank you
# 2  
Old 02-02-2011
Code:
grep "\b1.1\b" txt -A1 | tr '\n' ' ' | sed 's/date.*://'

# 3  
Old 02-02-2011
Code:
 $ ruby -ne 'print gets.split(":")[-1] if /revision 1.1$/' file

# 4  
Old 02-02-2011
through sed..
Code:
 sed -n '/revision 1.1$/N;s/\n.*:/:/p' inputfile > outfile

# 5  
Old 02-02-2011
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

Code:
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

Last edited by harjinder; 02-02-2011 at 03:26 AM.. Reason: Please use code tags
# 6  
Old 02-02-2011
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
Code:
sed -n '/revision 1.1$/N;s/\(.*\)\n.*\(auth.*\); .*/\1 \2/p' inputfile > outfile

The Following User Says Thank You to michaelrozar17 For This Useful Post:
harjinder (02-02-2011)
# 7  
Old 02-02-2011
a more complicated code:
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?
Login to Reply

« Previous Thread | Next Thread »
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
shell scripting and programmming kullu Shell Programming and Scripting 1 09-05-2011 11:27 PM
shell scripting and programmming kullu Shell Programming and Scripting 0 07-12-2011 02:44 AM
Perl scripting or shell scripting? Anna Hussie Web Programming 1 04-20-2011 04:08 AM
shell scripting and programmming harjinder Shell Programming and Scripting 1 03-01-2011 05:27 AM
Shell Scripting vs Perl scripting Pouchie1 What is on Your Mind? 2 02-10-2011 12:21 PM
shell scripting and programmming harjinder Shell Programming and Scripting 1 02-04-2011 12:48 AM
Shell scripting vs Perl scripting Pouchie1 What is on Your Mind? 14 09-06-2010 09:48 PM
Call Shell scripting from Perl Scripting. anupdas Shell Programming and Scripting 2 02-12-2010 07:07 AM
I am a newb to the C programmming language how do I make it interesting? yunusabd786 Programming 6 11-01-2008 02:27 PM
difference between AIX shell scripting and Unix shell scripting. haroonec Shell Programming and Scripting 2 04-12-2006 08:12 AM


All times are GMT -4. The time now is 06:14 AM.

Unix & Linux Forums Content Copyright©1993-2018. All Rights Reserved.
UNIX.COM Login
Username:
Password:  
Show Password