Splitting a column using awk

awk

I have a file like shown below. The 9th column has values joined by **.

chrXV   234346  234546  snR81   +       SNR81   chrXV   234357  0.0003015891774815342**0.131826816475   +
chrXV   234346  234546  snR81   +       SNR81   chrXV   234385  0.0002208827994288481**0.0118547789578  +
chrXV   234346  234546  snR81   +       SNR81   chrXV   234396  0.0001799579220002955**0.00583993781634 +
chrXV   234346  234546  snR81   +       SNR81   chrXV   234410  0.003451057940295026**0.00352844797952  +

I want to have an output where I can have the 2 values as sep columns. How can I do this in awk.

This is the output I want. Showing the first line of the output:

chrXV   234346  234546  snR81   +   SNR81   chrXV   234357  0.0003015891774815342   0.131826816475  +

Best Answer

No idea why people are using cat to pipe the file into awk, and the tr answer only translates one character into another, so any * is converted to a space.

Simple awk solution

awk -F"**" '$1=$1' OFS="\t" file 

For tab between all fields

awk 'sub(/\*\*/," "){$1=$1}1' OFS="\t" file

And one more

awk 'gsub(/(*| )+/,"\t")' file

Sed command

sed 's/[* ]\+/\t/g' file

tr command

tr -s '* ' '\t'  < file
Related Question