Casting to int in awk

前端 未结 3 882
猫巷女王i
猫巷女王i 2021-01-03 22:07

I\'m looking for a method to cast a string to an int in awk. I have the following which appears to be doing a string comparison

(note: field

3条回答
  •  清歌不尽
    2021-01-03 22:35

    You can just use +0. say variable v is your percentage value.

    $ awk -v v="80.1%" 'BEGIN{print v+0.1}'
    80.2
    

    You do not have to get rid of the % sign.

提交回复
热议问题