#!/bin/bash a=65535 out="" while [ $a -gt 0 ] do b=$(($a%2)) a=$(($a/2)) out="$b$out" done echo $out
#!/bin/bash
a=65535
out=""
while [ $a -gt 0 ]
do
b=$(($a%2))
a=$(($a/2))
out="$b$out"
done
echo $out