bc出力で改行を防ぐ方法

bc出力で改行を防ぐ方法

GNU v.1.06には次の例があります(行の長さに関する制限を認識しません)。

v=$(bc -l <<<"scale=100;4*a(1)"); echo $v

返品:

3.141592653589793238462643383279502884197169399375105820974944592307\ 
8164062862089986280348253421170676

この関数の出力からバックスラッシュとキャリッジリターンを削除できますか?または存在しないものを探していますか?

ベストアンサー1

少なくともGNUでは、環境変数をゼロ値にbc設定できます。BC_LINE_LENGTH

BC_LINE_LENGTH=0 bc -l <<<"scale=100;4*a(1)"

からman bc

BC_LINE_LENGTH
       This should be an integer specifying the number of characters in
       an  output  line  for  numbers.  This includes the backslash and
       newline characters for long numbers.  As an extension, the value
       of  zero  disables  the  multi-line feature.  Any other value of
       this variable that is less than 3 sets the line length to 70.

おすすめ記事