我在 GNU v. 1.06 中有以下示例(我无法确定与行长度有关的限制):
v=$(bc -l <<<"scale=100;4*a(1)"); echo $v
Run Code Online (Sandbox Code Playgroud)
返回:
3.141592653589793238462643383279502884197169399375105820974944592307\
8164062862089986280348253421170676
Run Code Online (Sandbox Code Playgroud)
是否可以删除此函数输出中的反斜杠和回车符,或者我正在寻找不存在的东西?
至少在 GNU 中bc
,您可以将环境变量设置BC_LINE_LENGTH
为零值,例如
BC_LINE_LENGTH=0 bc -l <<<"scale=100;4*a(1)"
Run Code Online (Sandbox Code Playgroud)
来自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.
Run Code Online (Sandbox Code Playgroud)