Help, filtering some info. from a file under "()"


 
Thread Tools Search this Thread
Top Forums UNIX for Advanced & Expert Users Help, filtering some info. from a file under "()"
# 1  
Old 09-10-2007
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 !! Smilie
# 2  
Old 09-10-2007
Code:
awk '{print $2}' FS="[()]" TEST.TXT

# 3  
Old 09-10-2007
Quote:
Originally Posted by radoulov
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 !!Smilie
# 4  
Old 09-10-2007
Could you poste a sample from TEST.TXT?
It has to be different from the lines you posted above ...
# 5  
Old 09-10-2007
Quote:
Originally Posted by radoulov
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.
# 6  
Old 09-11-2007
Quote:
Originally Posted by radoulov
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 !!
Smilie
# 7  
Old 09-11-2007
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

$

Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Bash script - Print an ascii file using specific font "Latin Modern Mono 12" "regular" "9"

Hello. System : opensuse leap 42.3 I have a bash script that build a text file. I would like the last command doing : print_cmd -o page-left=43 -o page-right=22 -o page-top=28 -o page-bottom=43 -o font=LatinModernMono12:regular:9 some_file.txt where : print_cmd ::= some printing... (1 Reply)
Discussion started by: jcdole
1 Replies

2. UNIX for Dummies Questions & Answers

Using "mailx" command to read "to" and "cc" email addreses from input file

How to use "mailx" command to do e-mail reading the input file containing email address, where column 1 has name and column 2 containing “To” e-mail address and column 3 contains “cc” e-mail address to include with same email. Sample input file, email.txt Below is an sample code where... (2 Replies)
Discussion started by: asjaiswal
2 Replies

3. UNIX for Advanced & Expert Users

AIX - io info get from "libperfstat" not match "iostat"

Hi, everyone. I need to write a program to get io info based on libperfstat. But the "write time" of a disk is just half of the value get from iostat. I'm confused and can't explain. Help please. How I calculate "write service time per sec": In iostat: write service... (0 Replies)
Discussion started by: jackliang
0 Replies

4. Shell Programming and Scripting

finding the strings beween 2 characters "/" & "/" in .txt file

Hi all. I have a .txt file that I need to sort it My file is like: 1- 88 chain0 MASTER (FF-TE) FFFF 1962510 /TCK T FD2TQHVTT1 /jtagc/jtag_instreg/updateinstr_reg_1 dff1 (TI,SO) 2- ... (10 Replies)
Discussion started by: Behrouzx77
10 Replies

5. Shell Programming and Scripting

awk command to replace ";" with "|" and ""|" at diferent places in line of file

Hi, I have line in input file as below: 3G_CENTRAL;INDONESIA_(M)_TELKOMSEL;SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL My expected output for line in the file must be : "1-Radon1-cMOC_deg"|"LDIndex"|"3G_CENTRAL|INDONESIA_(M)_TELKOMSEL"|LAST|"SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL" Can someone... (7 Replies)
Discussion started by: shis100
7 Replies

6. Shell Programming and Scripting

rearrange info of file in a "table"

Please I need to rearrange data acquired by USB port from a sensor network. The information is mixed and I need to convert it into a kind of table. This is my input file: Node 4D5A joined Temperature: 27,5 Humidity: 40 Dew Point: 23 No motion detected LUX: 389 Temperature: 28 Humidity: 41... (5 Replies)
Discussion started by: csecnarf
5 Replies

7. UNIX for Dummies Questions & Answers

Explain the line "mn_code=`env|grep "..mn"|awk -F"=" '{print $2}'`"

Hi Friends, Can any of you explain me about the below line of code? mn_code=`env|grep "..mn"|awk -F"=" '{print $2}'` Im not able to understand, what exactly it is doing :confused: Any help would be useful for me. Lokesha (4 Replies)
Discussion started by: Lokesha
4 Replies

8. UNIX for Dummies Questions & Answers

how do I dump "info ls" to a file?

how do I dump "info ls" to a file? I did $info ls >a <ENTER> but it didn't dump the whole thing. It only dumped chapter 10. (4 Replies)
Discussion started by: james hanley
4 Replies

9. Shell Programming and Scripting

Filtering/Finding a "Fortune" message

Hi, I have had a problem in Linux with the "Fortune" messages (unfortunately! :( ) and I need to trap the message again. It starts with a "IMPORTANT NOTICE". To capture this, I write a script as follows.. #!/bin/sh a=0 while ; do /usr/games/fortune >> fortune.txt a=`expr $a + 1` done... (4 Replies)
Discussion started by: oldtrash
4 Replies
Login or Register to Ask a Question