I am porting my shell script (quite big shell script) from bash to android shell (mksh shell).
In Android, printf
does not seem to be working the same way as it works in other Linux systems.
Sample code :
$ cat sample.sh
...
func1()
{
A=100
HEXA=`printf "%04x" ${A}`
echo "A - ${A} HEXA - ${HEXA}"
}
func1
This function's output is as follows.
$ ./sample.sh
A - 100 HEXA - 300000078
It is printing a really weird number.
I saw from other posts and from the manpage of mksh
that printf
is not recommended to be used in mksh
. My shell script, which is quite big, is using it very heavily. So, I want to handle this somehow. What are my options to handle this?