sed - splitting a data field into two based on a charatcer count -
my problem is:
i have data looks this:
>header_gh_x 12 15 53 43 23 25 45 56 4544 32 3 42 53 >header2 15 34 155 6 54 7 66 8888 23 12 23 45 but should this:
>header_gh_y 12 15 53 43 23 25 45 56 45 44 32 3 42 53 >header2 15 34 15 5 6 54 7 66 88 88 23 12 23 45 every second line consists of fields numbers can either 1 or 2 digits. has simple awk solution go every second line and, count characters in each field, , when there more 2 characters, split field 2 e.g. 245 becomes 24 5 , 2345 becomes 23 45
a sed one-liner it
sed -r 's/([0-9]{2})([0-9]+)/\1 \2/g' test
kent$ echo ">header_gh_x 12 15 53 43 23 25 45 56 4544 32 3 42 53 >header2 15 34 155 6 54 7 66 8888 23 12 23 45"|sed -r 's/([0-9]{2})([0-9]+)/\1 \2/g' >header_gh_x 12 15 53 43 23 25 45 56 45 44 32 3 42 53 >header2 15 34 15 5 6 54 7 66 88 88 23 12 23 45
Comments
Post a Comment