Greping certain lines


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Greping certain lines
# 1  
Old 02-21-2006
Greping certain lines

One of my outout is like this as shown below. How can I grep only the lines after the line "Affected files ...". No of lines after the line "Affected files ..." may vary.

$ cat file_A

Change 149133 by csaha@test_depo_csaha on 2006/02/08 01:40:57 *pending*

This is to test change #

Affected files ...

... //depot/users/csaha/chirantan/R&D1.doc#1 edit
... //depot/users/csaha/my-scripts/ecmsbuild.sh#2 edit
... //depot/users/csaha/my-scripts/eta noster gora.txt#1 add
... //depot/users/csaha/my-scripts/fs-dtls.sh#2 edit
... //depot/users/csaha/my-scripts/fs_usage_monitor.sh#2 edit
... //depot/users/csaha/my-scripts/server_info.sh#2 edit
# 2  
Old 02-21-2006
You could do this.

Code:
sed -n -e '/Affected files/,$p' | grep needle

It will gather all lines from "Affected files" till end of file.
# 3  
Old 02-21-2006
Thanks for the code dude

Only this was enough

Code:
$ cat file_A | sed -n -e '/Affected files/,$p' 
Affected files ...
 
... //depot/users/csaha/chirantan/R&D1.doc#1 edit
... //depot/users/csaha/my-scripts/ecmsbuild.sh#2 edit
... //depot/users/csaha/my-scripts/eta noster gora.txt#1 add
... //depot/users/csaha/my-scripts/fs-dtls.sh#2 edit
... //depot/users/csaha/my-scripts/fs_usage_monitor.sh#2 edit
... //depot/users/csaha/my-scripts/server_info.sh#2 edit

# 4  
Old 02-21-2006
Code:
cat file_A | sed -n -e '/Affected files/,$p'

That is a UUOC

Code:
sed -n -e '/Affected files/,$p' file_A

# 5  
Old 02-21-2006
UUOC means ?
# 6  
Old 02-21-2006
See this - UUOC
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

awk and greping between lines

i want to grab lines from a file that are between two patterns (including the lines that contain the pattern). here's what im currently doing: data.txt aaa bbb cccc ddd eee ffff ddd code: awk '/bbb/,/fff/ && $0 !~ /ddd/' cdsnmp.sh I want to grab lines between and including bbb... (5 Replies)
Discussion started by: SkySmart
5 Replies

2. Shell Programming and Scripting

Having trouble greping a variable

I'm trying to take a users input, and then such a text file to see if it contains it. I get an error when running it: "./Login.sh: Line 8: echo Username read username if ; then echo Login successful. else echo Failed to login. fi If someone could give me some input to where I'm... (4 Replies)
Discussion started by: Hegarz
4 Replies

3. Shell Programming and Scripting

greping $2 into a list

Hi When I run this command: lsuser -a auditclasses ALL I got: user1 auditclasses=general,objects,cron,files,rbac,audit,lvm,aixpert user2 auditclasses=general,objects,cron,files,rbac,audit,lvm,aixpert user3 auditclasses=general,objects,cron,files,rbac,audit,lvm,aixpert user4... (7 Replies)
Discussion started by: iga3725
7 Replies

4. Shell Programming and Scripting

need help in greping

Hi, i have to find a string in a file and positin of the string in the file would come in some particular interval. let's say file is 1-1000 lines and string is in from 200-300line. could any one suggest me how to get make the grep search for the string in that particular portion of the... (4 Replies)
Discussion started by: tarakant
4 Replies

5. Shell Programming and Scripting

Greping in between two different lines.

I know you could use the grep "something" -A200 flag to get all the lines past your pattern. Is there a way to get all the lines in between two patterns? The -a flag will not work since all lines in between the two patterns don't have a constant number. (4 Replies)
Discussion started by: jwillis0720
4 Replies

6. Shell Programming and Scripting

greping ip address

I have this line BTSRTRGRP-448-1-1 10.162.141.118/255.255.255.254 - I need to print only the IPADDRESS and not the subnet mask. If i use cut -c30-43 I get the ipaddress, where as in some cases if the last octet is of single digit (10.162.141.8/255.255.255.254) it... (2 Replies)
Discussion started by: miltonrods
2 Replies

7. Shell Programming and Scripting

Greping the required parameter...

Hi Friends, Urgently required to know this : I have a file which has several stanzas like below : CuDv: name = "hdisk3" status = 1 chgstatus = 2 ddins = "scdisk" location = "03-08-01-11,0" parent = "scsi1" connwhere =... (3 Replies)
Discussion started by: vijaya2006
3 Replies

8. Shell Programming and Scripting

need help in greping

i have a ksh script : #!/bin/ksh TZ=`date +%Z`+24 ;a=`date +%Y-%m-%d` b=`date +"%H:%M:%S"` cd /ednadtu3/u01/pipe/logs for i in Archiver1.log do cat $i | grep $a | grep $b >> /ednadtu3/u01/pipe/naveed/Insert_Date.txt done... (4 Replies)
Discussion started by: ali560045
4 Replies

9. UNIX for Dummies Questions & Answers

GREPing for Nulls

I just had a filesystem / file corruption issue on my HSP's server due to disk capacity limits and fileswapping. I discovered that certain files got corrupted when fileswapping was not successful and they ended up with a string of control characters, or what I believe to be nulls, in them. Does... (4 Replies)
Discussion started by: Dr. DOT
4 Replies

10. UNIX for Dummies Questions & Answers

Help with greping a field

Hi, Suppose I have a file as below and I just want the field Invoice Number from this file , How can I do it. /home/arbor>cat PH0034090202314800030IM-001 0Yp825XMilperra NSW 1891 189110H14V1Sp2871Yp300X Customer Service : 0000-368-81118H6.5V0Sp3130Yp50X ... (7 Replies)
Discussion started by: rooh
7 Replies
Login or Register to Ask a Question