我想绘制框图表格式文件,其数据已经在两列中。 Catch是第二列是十六进制的,需要是一些const(734)的额外倍数,即test.dat
amp 0x223
dupa 0x333
jasiu 0x4a4
halo 0xb1
最好的是在bash one liner中做到这一点。我结束了这个
cat test.dat |xargs printf '%s $(printf "scale=2; %d/734\\n" | bc)\n' |xargs -0 echo
但是打印出类似的东西
amp $(printf "scale=2; 547/734\n" | bc)
dupa $(printf "scale=2; 819/734\n" | bc)
jasiu $(printf "scale=2; 1188/734\n" | bc)
halo $(printf "scale=2; 177/734\n" | bc)
而不是计算第二个值。最后的回声应该做的工作,但没有做,为什么以及如何解决这个问题?
awk
救援!
$ awk -P '{printf("%s %d\n", $1, $2*734)}' file
amp 401498
dupa 601146
jasiu 871992
halo 129918
将第二个字段转换为十进制并与734相乘.-P
用于POSIX模式,可能会禁用许多其他有用的功能,但是此处不需要任何其他功能。
一些深夜的乐趣......
Perl救援! ;-)
perl -aE 'say $F[0] . " " . hex($F[1])/734' file
gnuplot
救援!
plot "test.dat" using 0:($2/734.0):xtic(1) with boxes