PDA

View Full Version : Converting an output to binary



5BallJuggler
February 8th, 2009, 11:36 PM
Can anyone help, i'd like the output from this command in a binary format please.

date -d now +%s

Thanks in advance
Phil

sisco311
February 9th, 2009, 12:06 AM
Can anyone help, i'd like the output from this command in a binary format please.

date -d now +%s

Thanks in advance
Phil

You can use bc to convert a number to base 2.
Homework?

5BallJuggler
February 9th, 2009, 12:14 AM
;)
not homework.

i want to display "unix" time in dec and binary in conky or a screenlet.

how would i use bc?

sisco311
February 9th, 2009, 12:18 AM
echo $(echo "obase=2; $(date +%s)" | bc)

Dr Small
February 9th, 2009, 12:18 AM
;)
not homework.

i want to display "unix" time in dec and binary in conky or a screenlet.

how would i use bc?

[drsmall@darkghost ~]$ echo 12*12 | bc
144

5BallJuggler
February 9th, 2009, 12:22 AM
[drsmall@darkghost ~]$ echo 12*12 | bc
144



echo $(echo "obase=2; $(date +%s)" | bc)

thanks very much guys, works a treat!:D