removing square braces from a particular column


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting removing square braces from a particular column
# 1  
Old 02-09-2010
removing square braces from a particular column

Hey Guys,

I have a text which has data like this


Code:
 
Taaaa AAA[0]     BBB SSSS $[test] yelpi
Taaaa mmmm[1]  kly  Tnnnw $[yelst] meta
Baaaa Qriek[3]  Trieh Mbjsd $[yuean] kingsq
....

I need to get an output like this

Code:
 
MAX AAA[0]
TEST BBB
RES SSSS
YUYT test
MED yelpi
 
MAX mmmm[1]
TEST  kly
RES Tnnnw
YUYT yelst
MED meta

I used the following script

Code:
 
awk '/^Taaaa/ {
print "MAX "  $2
print "TEST " $3
print "RES "   $4
print "YUYT " $5
print "MED "   $6
}' test > del1

In my output file del1. I am getting

Code:
 
MAX AAA[0]
TEST BBB
RES SSSS
YUYT $[test]
MED yelpi
MAX mmmm[1]
TEST kly
RES Tnnnw
YUYT $[yelst]
MED meta

so i need to remove the "$[" and "]" from only 5th column.. Is there an easy way to modify mny existing script to do so?? Please let me know.

Thanks,
Naveen

---------- Post updated at 03:38 PM ---------- Previous update was at 03:29 PM ----------

figured it out Smilie.. thanks

Code:
 
awk '/^Taaaa/ {
print "MAX "  $2
print "TEST " $3
print "RES "  $4
sub("\\$\\[","",$5); sub("\\]","",$5);print "YUYT " $5
print "MED "  $6
}' test > del1

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 use regex on particular column (Removing comma from particular column)?

Hi, I have pipe separated file which contains some data having comma(,) in it. I want to remove the comma(,) only from particular column without changing data in other columns. Below is the sample data file, I want to remove the comma(,) only from 5th column. $ cat file1 ABC | DEF, HIJ|... (6 Replies)
Discussion started by: Prathmesh
6 Replies

2. UNIX for Dummies Questions & Answers

Removing 2nd Column in Vi Editor

I have text like this M83-306 132 797 M83-312 145 685 M83-315 321 479 M83-319 654 193 M83-350 556 1184 M83-303 222 199 and I want to make it like this M83-306 797 M83-312 685 M83-315 ... (9 Replies)
Discussion started by: muhnandap
9 Replies

3. 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

4. Shell Programming and Scripting

Removing identical words in column

I have a file that needs to be cleaned up. Here is the file: Project Project John Project Gary Project Sean Project2 Project2 Lisa Project2 Tyler Project2 Sam Project3 Project3 Mike Project3 Bran I need the o/p to be: Project John Gary Sean Project2 (7 Replies)
Discussion started by: leepet01
7 Replies

5. Shell Programming and Scripting

Removing first column using awk script

I have this awk script. I have two different methods to remove the first column. However defining method = 1 in the BEGIN produces different results than when defining method = 1 later on instead. Any idea what it might be doing differently??? :rolleyes: BEGIN { Version = "V05" ... (4 Replies)
Discussion started by: kristinu
4 Replies

6. Shell Programming and Scripting

Help in removing 1st column in file

Hi All, I have a input file CT;RE23;DR33;FT44 CT;RE24;DR22;FT55 Here i need to make and output file with below structure i need to remove the first column: RE23;DR33;FT44 RE24;DR22;FT55 How can i do this do i need to write a for loop for this Having 19 posts you should be... (12 Replies)
Discussion started by: kam786sim
12 Replies

7. UNIX for Dummies Questions & Answers

Removing last ten characters from a column

I have a file that looks like this: hsa-miR-517b-4373244 0 4.116 hsa-miR-886-5p-4395304 1.173 1.95 hsa-miR-551b-4380945 1.62 1.722 hsa-miR-886-3p-4395305 1.479 3.074 hsa-miR-125a-3p-4395310 1.246 2.697 hsa-miR-874-4395379 1.985 1.721 I want it too look like this: ... (9 Replies)
Discussion started by: e3r1ck_ETT
9 Replies

8. UNIX for Dummies Questions & Answers

Removing comma after 3rd column

I have 10,000 lines to remove the commas after the 3rd column. Any help will be appreciated! Removing commas after the 3rd column Input aaaaa,bbbbb,cccccc,ddddddd aaaaa,bbbbb,cccccc aaaaa,bbbbb,cccccc,ddddddd,eeeeee aaaaa,bbbbb,cccccc,ddddddd,eeeeee,fffffff........(limit of comma is not... (13 Replies)
Discussion started by: buddyme
13 Replies

9. Shell Programming and Scripting

Removing Headers and a Column

I have a text file in unix with a layout like this Column 1 - 1-12 Column 2 - 13-39 Column 3 - 40-58 Column 4 - 59-85 Column 5 - 86-120 Columbn 6 - 121-131 The file also has a header on the first 6 lines of each page. Each page is 51 lines long. So I want to remove the header from each... (30 Replies)
Discussion started by: DerangedNick
30 Replies

10. Shell Programming and Scripting

removing a column from list

What I am trying to do is figure out how to remove a column from a list in a file, or from the command line. The opposite of cut -cX-Y file1 The file contains (result of who command) jhabi0 pts/ta Oct 8 16:22 llemo0 pts/1 Oct 8 15:30 rgood0 pts/2 Oct ... (3 Replies)
Discussion started by: jxh461
3 Replies
Login or Register to Ask a Question