bc Linux Commands
What is Linux bc Command?
Explanation
bc COMMAND:bc command is used for command line calculator. It is similar to basic calculator. By using which we can do basic mathematical calculations.
SYNTAX :
bc [options]
OPTIONS:
-c |
Compile only. The output is dc commands that are sent to the standard output. |
-l |
Define the math functions and initialize scale to 20, instead of the default zero. |
filename |
Name of the file that contains the basic calculator commands to be calculated this is not a necessary command. |
EXAMPLE:
-
bc
Output:
bc 1.06
Copyright 1991-1994,1997,1998,2000 Free Software Foundation,Inc.
This is free software with ABSOLUTELY NO WARRANTY.
For details type `warranty'.
9*2
18
The above command used is for mathematical calculations.
-
bc -l
Output:
bc 1.06
Copyright 1991-1994,1997,1998,2000 Free Software Foundation,Inc.
This is free software with ABSOLUTELY NO WARRANTY.
For details type `warranty'.
1+2
3
The above command displays the sum of '1+2'.
-
bc calc.txt
Output:
bc 1.06
Copyright 1991-1994,1997,1998,2000 Free Software Foundation,Inc.
This is free software with ABSOLUTELY NO WARRANTY.
For details type `warranty'.
3
'calc.txt' file have the following code:1+2. Get the input from file and displays the output.