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 10:52 PM
"sed" to check file size & echo " " to destination file jockey007 Shell Programming and Scripting 6 11-13-2007 06: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
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #8  
Old 09-11-2007
Registered User
 

Join Date: Feb 2007
Location: Pune, Dehradun (INDIA), Michigan(US)
Posts: 187
Wink

Quote:
Originally Posted by radoulov View Post
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

$


Hey thanks Buddy !!
..For such a descriptive reply !!

I am using AIX5.2, where i can use awk frequently. I have no idea abt gawk, mawk, nawk !!

ANyways !!...any other shortcut to filter the string value between () ??

Thanks !!
Reply With Quote
Forum Sponsor
  #9  
Old 09-11-2007
radoulov's Avatar
addict
 

Join Date: Jan 2007
Location: Milano, Italia/Варна, България
Posts: 1,935
With bash, zsh, ksh93:

Code:
cut -d\) -f1 <(cut -d\( -f2 yourfile)
Reply With Quote
  #10  
Old 09-11-2007
radoulov's Avatar
addict
 

Join Date: Jan 2007
Location: Milano, Italia/Варна, България
Posts: 1,935
Can you use sed?

Code:
sed 's/[^(]*(\([^)]*\)).*/\1/' yourfile
Reply With Quote
  #11  
Old 09-11-2007
radoulov's Avatar
addict
 

Join Date: Jan 2007
Location: Milano, Italia/Варна, България
Posts: 1,935
Or even:

Code:
while IFS='(' read a b;do echo "${b%%)*}";done<yourfile
Reply With Quote
Google The UNIX and Linux Forums
Reply

Tags
linux

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




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


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

Content Relevant URLs by vBSEO 3.2.0