Bash – Store 2^500 in a variable in bash

bashbc

I want to store the value of 2^500 in the variable DELTA.

I'm doing

export DELTA=$(echo "scale=2; 2^500" | bc)

but this does not set DELTA to 3273390607896141870013189696827599152216642046043064789483291368096133796404674554883270092325904157150886684127560071009217256545885393053328527589376. Instead, it sets it to

32733906078961418700131896968275991522166420460430647894832913680961\
33796404674554883270092325904157150886684127560071009217256545885393\
053328527589376

I tried the answers in this question (3 years old), using

export DELTA=$(echo "scale=2; 2^500" | bc | tr '\n' ' ') 

or

export DELTA=$(echo "scale=2; print 2^500" | bc | tr '\n' ' ')

but none of them work for setting the variable, only to echo it. Any idea?

Best Answer

echo "scale=2; 2^500" | bc | tr -d '\n\\'

Output:

3273390607896141870013189696827599152216642046043064789483291368096133796404674554883270092325904157150886684127560071009217256545885393053328527589376
Related Question