Reputation: 523
I have a file with 1056 columns in which every column looks like this (this is a subset of 4 columns):
0|0:0.2 0|0:0.03 0|0:0.02 0|0:0
0|0:0.04 0|0:0.7 0|0:0.05 0|0:1.3
I would like to remove the double dot and number part from each column and each line.
I've tried this code just for one column, but it is actually not working...
awk '{gsub(":[0-9]","",$1)}' file > file.mod
I would like that my output file looked like this:
0|0 0|0 0|0 0|0
0|0 0|0 0|0 0|0
Thank you very much in advanced :)
Upvotes: 1
Views: 60
Reputation: 8711
You can try Perl also
$ cat sonia.txt
0|0:0.2 0|0:0.03 0|0:0.02 0|0:0
0|0:0.04 0|0:0.7 0|0:0.05 0|0:1.3
$ perl -pe ' s/:\S+//g ' sonia.txt
0|0 0|0 0|0 0|0
0|0 0|0 0|0 0|0
$
Upvotes: 0
Reputation: 133538
If your Input_file is same as shown samples then could you please try following.
awk '{for(i=1;i<=NF;i++){sub(/:.*/,"",$i)}} 1' Input_file
Or adding solution from @Socowi comments as follows too.
awk '{gsub(":[0-9.]*",""); print}' Input_file
Upvotes: 1