shell scripting and programmming


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting shell scripting and programmming
# 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 03: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 04: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

This User Gave Thanks to michaelrozar17 For This Post:
# 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 or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

shell scripting and programmming

hi , i was trying a small script in sed as my main motive is to apppnd a sentence before a line and after a line. e.g this is the sentence which is present in many files and i want to append 2 more sentences in this sentence of mine. tanvi is good girl the result should come out as ... (1 Reply)
Discussion started by: kullu
1 Replies

2. Shell Programming and Scripting

shell scripting and programmming

hi i was trying the perl scripting with the new perforce and found the various issues which says u need to define a package in it..... wat can be the reason for this ....is there any basic requirement we need to install for running the perl scripts on perforce.... thanks kullu:rolleyes: (0 Replies)
Discussion started by: kullu
0 Replies

3. Web Development

Perl scripting or shell scripting?

i am going to study any one of the scripting languages mentioned above(shell 0r perl scripting) . Which is having more scope for a fresher? (1 Reply)
Discussion started by: Anna Hussie
1 Replies

4. Shell Programming and Scripting

shell scripting and programmming

how to set shell env variable from perl script ?? (1 Reply)
Discussion started by: harjinder
1 Replies

5. What is on Your Mind?

Shell Scripting vs Perl scripting

Gents, I have been working in a Solaris/Unix environment for about 9 months. I took some linux classses online before getting the job. But, I am not very good at scripting. I want to learn how to script. Do you think that I should start with Shell scripting or Perl? I wanted to continue with... (2 Replies)
Discussion started by: Pouchie1
2 Replies

6. Shell Programming and Scripting

shell scripting and programmming

what is much better ????? Perl or Shell Scripting???? (1 Reply)
Discussion started by: harjinder
1 Replies

7. What is on Your Mind?

Shell scripting vs Perl scripting

Hi all, I would like to start developping some good scripting skills. Do you think it would be best to start with shell scripting or Perl? I already got a fundation, really basics, in perl. but I am wondering what would be best to be good at first. Can you please help me determine which one to... (14 Replies)
Discussion started by: Pouchie1
14 Replies

8. Shell Programming and Scripting

Call Shell scripting from Perl Scripting.

Hi How to call a shell scripting through a Perl scripting? Actually I need some value from Shell scripting and passes in the Perl scripting. So how can i do this? (2 Replies)
Discussion started by: anupdas
2 Replies

9. Programming

I am a newb to the C programmming language how do I make it interesting?

I am a newb to the C programmming language how do I make it interesting? (6 Replies)
Discussion started by: yunusabd786
6 Replies

10. Shell Programming and Scripting

difference between AIX shell scripting and Unix shell scripting.

please give the difference between AIX shell scripting and Unix shell scripting. (2 Replies)
Discussion started by: haroonec
2 Replies
Login or Register to Ask a Question