Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

LouiseT

macrumors newbie
Original poster
Feb 11, 2013
3
0
Hi everyone
I have been trying to split content of one column into two. Sounds simple but I have not gotten it to work.
My file looks like this:
chr17 65505 65506 (#Coding_GN)@(#Coding_GN)
chr4 68144 68145 0!overlap@ (#Coding_GN_ensemble)
chr4 68199 68200 0!overlap@ (#Coding_GN_ensemble)

And I would like to split column 4 by @ so I get:

hr17 65505 65506 (#Coding_GN) (#Coding_GN)
chr4 68144 68145 0!overlap (#Coding_GN_ensemble)
chr4 68199 68200 0!overlap (#Coding_GN_ensemble)

Anyone know of a awk, sed or other UNIX inbuilt command/function which can do this?

Thanks
 

Flantec

macrumors newbie
May 31, 2009
7
0
Hi everyone
I have been trying to split content of one column into two. Sounds simple but I have not gotten it to work.
My file looks like this:
chr17 65505 65506 (#Coding_GN)@(#Coding_GN)
chr4 68144 68145 0!overlap@ (#Coding_GN_ensemble)
chr4 68199 68200 0!overlap@ (#Coding_GN_ensemble)

And I would like to split column 4 by @ so I get:

hr17 65505 65506 (#Coding_GN) (#Coding_GN)
chr4 68144 68145 0!overlap (#Coding_GN_ensemble)
chr4 68199 68200 0!overlap (#Coding_GN_ensemble)

Anyone know of a awk, sed or other UNIX inbuilt command/function which can do this?

Thanks

It does not appear that you are splitting column 4, but are just removing the "@" from it. Assuming that I am understanding this correctly, use sed to just remove the "@" symbols.

cat somefile | sed 's/@//g'
 

LouiseT

macrumors newbie
Original poster
Feb 11, 2013
3
0
I would like 5 columns in output

No, I can see that does not look like I split the 4th column. That was an seperator effect that glided.
I would like 5 column in output.
ex (set op a little different ($ = column):
input:
$1= chr17
$2= 65505
$3= 65506
$4= (#Coding_GN)@(#Coding_GN)

Output:
$1 = chr17
$2 = 65505
$3 = 65506
$4 = (#Coding_GN)
$5 = (#Coding_GN)
 

chown33

Moderator
Staff member
Aug 9, 2009
10,999
8,887
A sea of green
Use the 'tr' command to translate '@' to ' ' (space).

You can also use 'tr' to squeeze multiple spaces into a single space.

See 'man tr'.

If you have a problem or it doesn't work, post the command that doesn't work, then describe what happens and what you expected to happen.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.