Remove brackets { } in the data


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Remove brackets { } in the data
# 1  
Old 12-04-2011
Remove brackets { } in the data

Hello folks,

I have a data file in which each line has 54 numbers, and every 3 numbers are bracketed. So totally 18 pairs of brackets in each line.

A typical line is like:
Code:
 {29.187000274658203 -16.148000717163086 -0.9380000233650208} {30.63800048828125 -15.977999687194824 -0.3569999933242798} {31.273000717163086 -14.661999702453613 -0.8920000195503235} {31.34600067138672 -14.612000465393066 -2.4649999141693115} {31.944000244140625 -13.251999855041504 -2.937999963760376} {32.167999267578125 -12.991999626159668 -4.390999794006348} {30.98200035095215 -13.326000213623047 -5.288000106811523} {30.961999893188477 -12.444000244140625 -6.568999767303467} {29.742000579833984 -12.843999862670898 -7.388999938964844} {29.194000244140625 -12.116999626159668 -8.392999649047852} {27.920000076293945 -12.36400032043457 -9.166000366210938} {28.06599998474121 -12.16100025177002 -10.722000122070313} {28.545000076293945 -10.763999938964844 -11.09000015258789} {28.238000869750977 -10.347000122070313 -12.569000244140625} {28.989999771118164 -11.258999824523926 -13.631999969482422} {28.481000900268555 -11.187999725341797 -15.022000312805176} {29.47800064086914 -10.324999809265137 -15.859000205993652} {29.010000228881836 -9.907999992370605 -17.30699920654297}

When reading it into Matlab, I want to get a clean file without brackets.
Is there a way to process the date file using a shell script?

Your help will be highly appreciated.
Todd

---------- Post updated at 02:49 AM ---------- Previous update was at 02:35 AM ----------

Search this board and seems this code works
Code:
sed 's/[!@#\$%^&*()]//g' filename > newfile

# 2  
Old 12-04-2011
Code:
sed 's/[{}]//g' filename > newfile

# 3  
Old 12-04-2011
Quote:
Originally Posted by rockytodd
seems this code works
Code:
sed 's/[!@#\$%^&*()]//g' filename > newfile

I don't see how this would remove braces.
# 4  
Old 12-04-2011
You are correct. The code does not remove the braces.
# 5  
Old 12-04-2011
You could also try tr:

Code:
tr -d '}{' < infile > outfile

# 6  
Old 12-05-2011
In nawk ..
Code:
$ nawk '{gsub(/[{}]/,"")};1' infile

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to remove the text between all curly brackets from text file?

Hello experts, I have a text file with lot of curly brackets (both opening { & closing } ). I need to delete them alongwith the text between opening & closing brackets' pair. For ex: Input:- 59. Rh1 Qe4 {(Qf5-e4 Qd8-g8+ Kg6-f5 Qg8-h7+ Kf5-e5 Qh7-e7+ Ke5-f5 Qe7-d7+ Qe4-e6 Qd7-h7+ Qe6-g6... (6 Replies)
Discussion started by: prvnrk
6 Replies

2. Shell Programming and Scripting

Remove multiline text between brackets

I have some text in a file like so This is {the first day of} my life. What I would like as output is This is my life. Any text between the curly braces is removed. In the forums I've found statements like sed 's/<*>//g' but the problem is that I think that... (12 Replies)
Discussion started by: climatron
12 Replies

3. Shell Programming and Scripting

Remove everything inside of brackets

I need to use something bash related to remove everything inside of brackets. For example. In the following: abc<def>ghi<jkl>mno the result should be: abcghimno (4 Replies)
Discussion started by: locoroco
4 Replies

4. Shell Programming and Scripting

Remove whatever is mention in brackets

Hi all My previous question was complicated let me simplify it I have to just remove whatever is present in bracket () along with brackets ERCC1 (PA155) Platinum compounds (PA164713176) Allele A is not associated with response to Platinum compounds in women with Ovarian Neoplasms as... (2 Replies)
Discussion started by: Priyanka Chopra
2 Replies

5. Shell Programming and Scripting

Remove brackets repeats and separate in columns

Hi all, I want to remove the remove bracket sign ( ) and put in the separate column I also want to remove the repeated entry like in first row in below input (PA156) is repeated ESR1 (PA156) leflunomide (PA450192) (PA156) leflunomide (PA450192) CHST3 (PA26503) docetaxel... (4 Replies)
Discussion started by: manigrover
4 Replies

6. Shell Programming and Scripting

remove brackets and put it in a column and remove repeated entry

Hi all, I want to remove the remove bracket sign ( ) and put in the separate column I also want to remove the repeated entry like in first row in below input (PA156) is repeated ESR1 (PA156) leflunomide (PA450192) (PA156) leflunomide (PA450192) CHST3 (PA26503) docetaxel... (2 Replies)
Discussion started by: manigrover
2 Replies

7. Shell Programming and Scripting

Extracting Data between Tags with square Brackets

Hello @all, first, sorry for my bad english language. I try to extract with bash an text inside of a html page witch is finding between two tags. There is only one Tag in this file. Here is an example: Wert... (2 Replies)
Discussion started by: hennerich
2 Replies

8. Shell Programming and Scripting

Remove text between brackets

How can I use bash to remove all text between "<" and ">" in a file? (1 Reply)
Discussion started by: locoroco
1 Replies

9. Shell Programming and Scripting

Delete text between square brackets and also delete those square brackets using sed or awk

Hi All, I have a text file which looks like this: computer programming systems engineering I want to get rid of these square brackets and also the text that is inside these brackets. So that my final text file looks like this: computer programming systems engineering I am using... (3 Replies)
Discussion started by: shoaibjameel123
3 Replies

10. Shell Programming and Scripting

How to extract data from BNC xml with reference brackets?

I have data like the following pattern: <change date="2000-01-09" who="#OUCS">Updated all catrefs</change> <change date="2000-01-08" who="#OUCS">Manually updated tagcounts, titlestmt, and title in source</change> <change date="1999-09-13" who="#UCREL">POS codes revised for BNC-2; header... (14 Replies)
Discussion started by: Johnivy
14 Replies
Login or Register to Ask a Question