Cleanup between parenthesis


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Cleanup between parenthesis
# 1  
Old 02-28-2010
Cleanup between parenthesis

Hi,

I am trying to clean up data between parenthesis () in a file.

See example below....

Code:
 
 
Input File : 
 
(New York) Chicago (London)    
New York (Chicago) London      
New York Chicago (London)      
(New York) (Chicago) (London)  
New York (Chicago)            
  

Output File : 
 
Chicago   
New York  London      
New York Chicago 
 
New York

I have the following awk statement so far but it is not doing what I am trying to accomplish.

Code:
cat test.dat | awk 'BEGIN{FS="("}{print $1}END { }' > output.dat

Please advise.

Thanks..
# 2  
Old 02-28-2010
1. Useless use of cat.

2. use the following sed solution,

Code:
sed 's/([^)]*)//g' test.dat

3. If that fits, use inplace editing or output redirection according to your requirement.
# 3  
Old 02-28-2010
Thanks thegeek. It worked great.....
# 4  
Old 03-01-2010
Try:

Code:
awk 'gsub(/\([A-Za-z ]+\)/,"",$0)' file

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Removing spaces between parenthesis ()

Hello, i 've go a file with the following text: oracle@das (J005) 0 oracle@das (J008) 0 oracle@das (J050) 0 oracle@das (J038) ... (15 Replies)
Discussion started by: nms
15 Replies

2. Shell Programming and Scripting

How to get value from a close and open parenthesis?

Hi Gurus, I have an input like the one below. What i wanted to achieved is to create a select statement based from that information INPUTInsert into table_name (col1,col2,col3,col4,col5,DATE1,DATE2,col6,col7,col8,col9,col10,col11) values (6752,14932156,24,'ALL','Staff',to_date('04/17/2017... (6 Replies)
Discussion started by: ernesto
6 Replies

3. UNIX for Dummies Questions & Answers

Renaming files to remove everything before one parenthesis

Hi, I have files in a folder that I would like all renamed without the preceding number and parenthesis. For example, I have files of the name 08) Great Good Fine Ok - Not Going Home 09) Roosevelt - Small Hours 10) RAC - I Should've Guessed Feat. SPEAK and I would like them all to be... (4 Replies)
Discussion started by: jyu429
4 Replies

4. Shell Programming and Scripting

sed help adding parenthesis

I have the following data and want to put parenthis around the numbers: PARTITION PERIOD_MIN VALUES LESS THAN 10649 TABLESPACE ODS_DAILY_MF_AUM, PARTITION PERIOD_10649 VALUES LESS THAN 10650 TABLESPACE ODS_DAILY_MF_AUM, PARTITION PERIOD_10650 VALUES LESS THAN 10651 TABLESPACE... (2 Replies)
Discussion started by: BeefStu
2 Replies

5. Shell Programming and Scripting

Need help with Sed (replacing parenthesis and comma)

I have the following text as an input text: input.txt Results('Toilet', 'Sink', ) and i want to remove the last comma so the output is output.txt Results('Toilet', 'Sink' ) I tried using the following sed command, but I get a parsing error: sed s/, \)/\)/g input.txt >... (5 Replies)
Discussion started by: jl487
5 Replies

6. Shell Programming and Scripting

extract first argument in parenthesis

I have a file that, among other things, contains a tuple with words and the word count. I want to make a list of the words only. Ex: My file words.txt looks like: 0.1 sw-wn 9 - n: 97/903 p: 107/893neg: (film,771.1) | (movie,717.1) | (like,690.1) | (just,621.1) | (it's,607.1) | (time,543.1) |... (4 Replies)
Discussion started by: erinbot
4 Replies

7. Shell Programming and Scripting

use of parenthesis() in shell programming

What's the use of parenthesis () in shell programming ? I saw this in one of the posts in this forum : echo $($1) What confounded me was that it evaluated the inner expression and then the outer one, almost like eval. It seemed like it did this in passes. (2 Replies)
Discussion started by: daudiam
2 Replies

8. UNIX for Dummies Questions & Answers

Problem in extracting the string between parenthesis

Hi Team, I am not able to extract string between parenthesis.I need to extract string between first parenthesis only. Please find the sample data and code. But the below my code is returning "DW_EFD_TXN_ID", "PRCS_DTE" & INITIAL 52428800 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645... (12 Replies)
Discussion started by: suriyavignesh
12 Replies

9. Programming

how to check parenthesis in MSVC++

how do i turn on the option to check for opening and closing parenthesis in Microsoft VC++? I remember there is a setting somewhere in the options in the MS VC++ environment but not sure.. thanks (4 Replies)
Discussion started by: npatwardhan
4 Replies

10. UNIX for Dummies Questions & Answers

another sed question about parenthesis

hi, I'm trying to use sed to erase everything, up to, and including, the first closing parenthesis. for example: input: blah blah blah (aldj) test (dafs) test test. output: test (dafs) test test. how would i do this? I was fooling around with the parenthesis, and i only got it to apply to... (5 Replies)
Discussion started by: gammaman
5 Replies
Login or Register to Ask a Question