카테고리 없음

string to integer in bash

RootFriend 2016. 11. 30. 14:13

출처 : http://stackoverflow.com/questions/12821715/convert-string-into-integer-in-bash-script



Constants with a leading 0 are interpreted as octal numbers.

You can remove the leading zero by parameter expansion:

hour=${hour#0}

or force base-10 interpretation:

$((10#$hour + 1))


저작자표시 비영리 변경금지 (새창열림)