Use at own risk. Programs haven't been thoroughly tested.
function: dec2bin
A simple BASH function convert a decimal to a binary string
Info
@author Kevin van Zonneveld
@version 0.7
@link http://kevin.vanzonneveld.net
@param (integer) INPUT the integer to convert
@version 0.7
@link http://kevin.vanzonneveld.net
@param (integer) INPUT the integer to convert
Example
Usage
Outputs
100000000
dec2bin 256Outputs
100000000
Source Code
download source#!/bin/bash # function dec2bin { input=$1 result="" while [ $input -gt 0 ]; do if [ $((input%2)) -gt 0 ]; then result="1$result" else result="0$result" fi input=$((input/2)) done; }
No comments. Be the first!