bash - Converting string of ASCII characters to string of corresponding decimals -


may introduce problem destroyed weekend. have biological data in 4 columns

@id:::12345/1 acgactacga text !"#$%vwxyz   @id:::12345/2 tatgacgacta text :;<=>?vwxyz 

i use awk edit first column replace characters : , / -
convert string in last column comma-separated string of decimals correspond each individual ascii character (any character ranging ascii 33 - 126).

@id---12345-1 acgactacga text 33,34,35,36,37,118,119,120,121,122   @id---12345-2 tatgacgacta text 58,59,60,61,62,63,86,87,88,89,90 

the first part easy, i'm stuck second. i've tried using awk ordinal functions , sprintf; can former work on first char in string , can latter convert hexidecimal decimal , not spaces. tried bash function

$ od -t d1 test3 | awk 'begin{ofs=","}{i = $1; $1 = ""; print $0}'  

but don't know how call function within awk. prefer use awk have downstream manipulations can done in awk.

many in advance

perl soltuion:

perl -lnae '$f[0] =~ s%[:/]%-%g; $f[-1] =~ s/(.)/ord($1) . ","/ge; chop $f[-1]; print "@f";' < input 

the first substitution replaces : , / in first field dash, second 1 replaces each character in last field ord , comma, chop removes last comma.


Comments

Popular posts from this blog

html5 - What is breaking my page when printing? -

html - Unable to style the color of bullets in a list -

c# - must be a non-abstract type with a public parameterless constructor in redis -