The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
How to parse through a file and based on condition form another output file sivasu.india UNIX for Advanced & Expert Users 6 02-28-2008 04:59 AM
Need help to parse the file navsharan Shell Programming and Scripting 3 01-17-2008 03:58 PM
Parse XML file viki Shell Programming and Scripting 5 04-13-2007 04:25 AM
How to parse a XML file using PERL and XML::DOm girigopal Shell Programming and Scripting 0 06-27-2005 06:46 AM
using getopt to parse a file coolguyshail Shell Programming and Scripting 1 06-08-2005 06:58 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 03-27-2007
sbasetty sbasetty is offline
Registered User
  
 

Join Date: Sep 2006
Posts: 75
Parse file

Hi Friends,

I have a file in the format shown (Name followed by address
I need only the address part please see the output.
I have tried using nawk but I am not getting the desired output.



SAM
ADDRS 64874 FRANKLYN DR
IRVINE TX - 74394;
538 FRED ASSOCIATES
PETER
ADDRS 84734 PANTHER CREEK
OWENSMOUTH MI - 88347;
3643 HARRIS

**********************output

ADDRS 64874 FRANKLYN DR
IRVINE TX - 74394;
ADDRS 84734 PANTHER CREEK
OWENSMOUTH MI - 88347;


************

nawk 'BEGIN{RS="" ; FS = "\n"}
{
flag=0;
for( i = 1;i <= NF; ++i )
{
if (match ($i , "^ADDRS" ))
{ flag=1; break; }
}

if (flag == 1) print
}' a

******************************
Thanks a Lot in advance

S
  #2 (permalink)  
Old 03-27-2007
matrixmadhan matrixmadhan is offline Forum Advisor  
Technorati Master
  
 

Join Date: Mar 2005
Location: leaf node in B+ tree
Posts: 2,944
Code:
awk '{ if ( $0 ~ "^ADDRS" ) { print; getline tmp; print tmp } }' filename
  #3 (permalink)  
Old 03-27-2007
sbasetty sbasetty is offline
Registered User
  
 

Join Date: Sep 2006
Posts: 75
I would like to have the output between
"ADDRS" and ";" only
with this input I am not getting the address part.

Can you please help

SAM
ADDRS 64874 FRANKLYN DR
IRVINE TX -
'74394;
538 FRED ASSOCIATES
PETER
ADDRS 84734 PANTHER CREEK
OWENSMOUTH MI - 88347;
3643 HARRIS
  #4 (permalink)  
Old 03-27-2007
anbu23 anbu23 is offline Forum Advisor  
Registered User
  
 

Join Date: Mar 2006
Location: Bangalore,India
Posts: 1,398
Quote:
Originally Posted by sbasetty
I would like to have the output between
"ADDRS" and ";" only
with this input I am not getting the address part.

Can you please help

SAM
ADDRS 64874 FRANKLYN DR
IRVINE TX -
'74394;
538 FRED ASSOCIATES
PETER
ADDRS 84734 PANTHER CREEK
OWENSMOUTH MI - 88347;
3643 HARRIS
Code:
sed -n "/^ADDRS/,/;/p" file
  #5 (permalink)  
Old 03-27-2007
sbasetty sbasetty is offline
Registered User
  
 

Join Date: Sep 2006
Posts: 75
Thank you very much guys It worked
  #6 (permalink)  
Old 03-27-2007
anbu23 anbu23 is offline Forum Advisor  
Registered User
  
 

Join Date: Mar 2006
Location: Bangalore,India
Posts: 1,398
Code:
sed -n "/^ADDRS/{N;p}" file
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 04:07 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0