- Code: Select all
$ echo "scale=1000; 4*a(1)" | bc -l
If you want to calculate large amounts of data, I recommend saving the output to a text file. It can be done like this:
- Code: Select all
$ echo "scale=1000; 4*a(1)" | bc -l > pi.txt
$ echo "scale=1000; 4*a(1)" | bc -l
$ echo "scale=1000; 4*a(1)" | bc -l > pi.txt
3.141592653589793238462643383279502884197169399375105820974944592307\
81640628620899862803482534211706798214808651328230664709384460955058\
22317253594081284811174502841027019385211055596446229489549303819644\
28810975665933446128475648233786783165271201909145648566923460348610\
export BC_LINE_LENGTH=0
echo "scale=1000; 4*a(1)" | bc -l
Bloom wrote:BC uses a default line length of 70 characters and will "wrap' when that is reached.
Export BC_LINE_LENGTH=0 if you don't want that. Example:
- Code: Select all
export BC_LINE_LENGTH=0
echo "scale=1000; 4*a(1)" | bc -l
Return to Docs, Howtos, Tips & Tricks
Users browsing this forum: No registered users and 5 guests