string - Split rows into Columns -
string - Split rows into Columns -
in next illustration want split lines 2 columns column 1 string of letters , columns 2 number after "-" sign.
>1-1112309 gtttccgtagtgtagtggttatcacgttcgcct >2-787704 tgaggtagtaggttgtatagtt >3-736193 gtttccgtagtgtagtggttatcacgttcgcc >4-671373 tgtaaacatcctcgactggaagct
desired output:
gtttccgtagtgtagtggttatcacgttcgcct 1112309 tgaggtagtaggttgtatagtt 787704 gtttccgtagtgtagtggttatcacgttcgcc 736193 tgtaaacatcctcgactggaagct 671373
another awk
command,
$ awk -v rs="\n>" '{gsub (/\n/," "); gsub (/^.*-/,"",$1); printf "%-40s %d\n", $2,$1}' file gtttccgtagtgtagtggttatcacgttcgcct 1112309 tgaggtagtaggttgtatagtt 787704 gtttccgtagtgtagtggttatcacgttcgcc 736193 tgtaaacatcctcgactggaagct 671373
rs set \n>
. splits input file records according value(\n>
) in rs variable.
gsub (/\n/," ") # replaces newlines in each record space. gsub (/^.*-/,"",$1) # removes characters upto - in column1. printf "%-40s %d\n", $2,$1 # prints column2, column1 in formatted way.
string awk
Comments
Post a Comment