The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Advanced & Expert Users
Google UNIX.COM


UNIX for Advanced & Expert Users Advanced UNIX and Linux questions go here. Expert-to-Expert.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Explain the line "mn_code=`env|grep "..mn"|awk -F"=" '{print $2}'`" Lokesha UNIX for Dummies Questions & Answers 4 12-19-2007 09:52 PM
"sed" to check file size & echo " " to destination file jockey007 Shell Programming and Scripting 6 11-13-2007 05:00 PM
Need info:"talk,write and wall" mr.anilbabu UNIX for Dummies Questions & Answers 1 07-23-2006 01:27 AM
how do I dump "info ls" to a file? james hanley UNIX for Dummies Questions & Answers 4 07-05-2006 06:36 AM
Filtering/Finding a "Fortune" message oldtrash Shell Programming and Scripting 4 05-13-2005 04:16 AM

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 09-10-2007
Registered User
 

Join Date: Feb 2007
Location: Pune, Dehradun (INDIA), Michigan(US)
Posts: 187
Help, filtering some info. from a file under "()"

I HAVE A FILE "TEXT.TXT" WHICH CONTAINS FOLLOWING :

CHANNEL(SYSTEM.DEF.CLUSRCVR) CHLTYPE(CLUSRCVR)
CHANNEL(TO.XYZ) CHLTYPE(CLUSRCVR)

NOW I WANT THE NAMES WRITTEN BETWEEN THE BRACES () UNDER COLUMN ONE, THAT IS, TO.XYZ and SYSTEM.DEF.CLUSRCVR.

USING awk i can get the first column, but then how to proceed further ?
I am doing like this :

sed -n '/CHANNEL/p' TEST.TXT | awk '{print $1 ;}' | tr '()' ' ' | awk '{print $2;}' | tr ')' ' '

And it does the objective , but i want something more presize and good option !!

ASAP Any help, genius ??
Thanks !!
Reply With Quote
Forum Sponsor
  #2 (permalink)  
Old 09-10-2007
radoulov's Avatar
addict
 

Join Date: Jan 2007
Location: Milan, Italy/Varna, Bulgaria
Posts: 1,391
Code:
awk '{print $2}' FS="[()]" TEST.TXT
Reply With Quote
  #3 (permalink)  
Old 09-10-2007
Registered User
 

Join Date: Feb 2007
Location: Pune, Dehradun (INDIA), Michigan(US)
Posts: 187
Quote:
Originally Posted by radoulov View Post
Code:
awk '{print $2}' FS="[()]" TEST.TXT
Hey thanks for your reply !!

Its giving statements within the braces(), BUT it gives something more then that too. Its given below :
$ awk '{print $2}' FS="[()]" text.txt
----------------------------------
C



*

SYSTEM.DEF.CLUSRCVR

TO.EAIDVBR1



----------------------------------

under "---" O/P is like shown above, more blank lines, C, *
Don't know from where its being generated ?

Please if you can rectify this ??
Thanks !!
Reply With Quote
  #4 (permalink)  
Old 09-10-2007
radoulov's Avatar
addict
 

Join Date: Jan 2007
Location: Milan, Italy/Varna, Bulgaria
Posts: 1,391
Could you poste a sample from TEST.TXT?
It has to be different from the lines you posted above ...
Reply With Quote
  #5 (permalink)  
Old 09-10-2007
Registered User
 

Join Date: Feb 2007
Location: Pune, Dehradun (INDIA), Michigan(US)
Posts: 187
Quote:
Originally Posted by radoulov View Post
Could you poste a sample from TEST.TXT?
It has to be different from the lines you posted above ...
CHANNEL(SYSTEM.DEF.CLUSRCVR) CHLTYPE(CLUSRCVR)
CHANNEL(TO.EAIDVBR1) CHLTYPE(CLUSRCVR)


i HAVE THIS MUCH ONLY IN A FILE.
Reply With Quote
  #6 (permalink)  
Old 09-11-2007
Registered User
 

Join Date: Feb 2007
Location: Pune, Dehradun (INDIA), Michigan(US)
Posts: 187
Quote:
Originally Posted by radoulov View Post
Could you poste a sample from TEST.TXT?
It has to be different from the lines you posted above ...
Hey Radoulov,

Can you please check the hint given by you only, once again...!!
I have given the Contents already of the file that i am using. Can you please
help me in that ?

Please check it !!
Reply With Quote
  #7 (permalink)  
Old 09-11-2007
radoulov's Avatar
addict
 

Join Date: Jan 2007
Location: Milan, Italy/Varna, Bulgaria
Posts: 1,391
With cut & paste from your post.

on Linux:

Code:
% cat file
CHANNEL(SYSTEM.DEF.CLUSRCVR) CHLTYPE(CLUSRCVR)
CHANNEL(TO.EAIDVBR1) CHLTYPE(CLUSRCVR)
% gawk '{print $2}' FS="[()]" file
SYSTEM.DEF.CLUSRCVR
TO.EAIDVBR1
% mawk '{print $2}' FS="[()]" file
SYSTEM.DEF.CLUSRCVR
TO.EAIDVBR1
on Solaris:

Code:
$ /usr/xpg4/bin/awk '{print $2}' FS="[()]" file
SYSTEM.DEF.CLUSRCVR
TO.EAIDVBR1
$ nawk '{print $2}' FS="[()]" file
SYSTEM.DEF.CLUSRCVR
TO.EAIDVBR1
Doesn't work with the old awk on Solaris, but gives a different result
(produce no output at all):

Code:
$ awk '{print $2}' FS="[()]" file

$
Reply With Quote
Google UNIX.COM
Reply

Tags
linux

Thread Tools
Display Modes




All times are GMT -7. The time now is 07:07 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008 The CEP Blog All Rights Reserved -Ad Management by RedTyger Visit The Global Fact Book

Content Relevant URLs by vBSEO 3.2.0