@AndreaCorbellini - Personal preference. In general, I use printf '%s\n' foo instead of echo for a variety of reasons (mostly portability), for the same reason, I don't use it here.
–
Chris DownFeb 20 '13 at 5:24

@ChrisDown: I though this question was explicitly about Bash (which has a well-implemented echo builtin). My bad!
–
Andrea CorbelliniFeb 20 '13 at 9:49

You can use bc for this by manipulating the ibase and obase parameters:

The trick is that you need to be explicit about the bases. So if your ibase is 2, then if you set your obase to 10, it won't do anything, as 10 in binary is 2. Hence you need to use hexadecimal notation.

This second example is wrong -- 'F' would be base 15, not 16 (decimal 16 in hex is 10, not F). Try echo 'ibase=2;obase=F;1111 which should equal decimal 15, ie. F in hex. It comes out as 10, which it is in base 15 (digits 0-E). It is also easier if you state the obase first, eg: echo 'obase=16;ibase=2;1111'|bc. No confusion.
–
goldilocksFeb 19 '13 at 7:21

Now it is worst. Once you set ibase, you have to provide input in that base, even for obase. So in your example would be echo 'ibase=2;obase=10000;11110001011010'|bc. Better listen to goldilocks's advice and reverse the order – first set obase, then ibase.
–
manatworkFeb 26 '13 at 18:08