×
UNIX.COM Login
Username:
Password:  
Show Password






👤


Shell Programming and Scripting

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

👤 Login to reply

 
Thread Tools Search this Thread Display Modes
    #1  
Old 02-02-2011
harjinder harjinder is offline
Registered User
 
Join Date: Feb 2011
Last Activity: 9 February 2015, 12:23 AM EST
Posts: 14
Thanks: 3
Thanked 0 Times in 0 Posts
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
Sponsored Links
    #2  
Old 02-02-2011
homeboy's Unix or Linux Image
homeboy homeboy is offline
Registered User
 
Join Date: Oct 2009
Last Activity: 21 June 2013, 3:39 AM EDT
Posts: 129
Thanks: 27
Thanked 11 Times in 11 Posts
Code:
grep "\b1.1\b" txt -A1 | tr '\n' ' ' | sed 's/date.*://'

Sponsored Links
    #3  
Old 02-02-2011
kurumi kurumi is offline
Resident Ruby Wrangler
 
Join Date: Dec 2009
Last Activity: 6 February 2016, 7:08 AM EST
Posts: 602
Thanks: 2
Thanked 83 Times in 78 Posts
Code:
 $ ruby -ne 'print gets.split(":")[-1] if /revision 1.1$/' file

    #4  
Old 02-02-2011
michaelrozar17's Unix or Linux Image
michaelrozar17 michaelrozar17 is offline
Registered User
 
Join Date: Jul 2010
Last Activity: 22 September 2016, 3:57 AM EDT
Location: IN
Posts: 894
Thanks: 15
Thanked 183 Times in 174 Posts
through sed..
Code:
 sed -n '/revision 1.1$/N;s/\n.*:/:/p' inputfile > outfile

Sponsored Links
    #5  
Old 02-02-2011
harjinder harjinder is offline
Registered User
 
Join Date: Feb 2011
Last Activity: 9 February 2015, 12:23 AM EST
Posts: 14
Thanks: 3
Thanked 0 Times in 0 Posts
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
Sponsored Links
    #6  
Old 02-02-2011
michaelrozar17's Unix or Linux Image
michaelrozar17 michaelrozar17 is offline
Registered User
 
Join Date: Jul 2010
Last Activity: 22 September 2016, 3:57 AM EDT
Location: IN
Posts: 894
Thanks: 15
Thanked 183 Times in 174 Posts
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)
Sponsored Links
    #7  
Old 02-02-2011
homeboy's Unix or Linux Image
homeboy homeboy is offline
Registered User
 
Join Date: Oct 2009
Last Activity: 21 June 2013, 3:39 AM EDT
Posts: 129
Thanks: 27
Thanked 11 Times in 11 Posts
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?
Sponsored Links
👤 Login to reply

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
Android Scripting Environment: Shell Scripting and Android Neo Android 0 01-03-2011 03:10 PM
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 12:15 AM.

Unix & Linux Forums Content Copyright©1993-2018. All Rights Reserved.