Linux dc Command
What is Linux dc Command?
Explanation
dc COMMAND:dc command is a desk calculator command and it's very similar to basic calculator. It is used to easily calculate all the basic arithmetic operations. It is older version compared to bc command.
SYNTAX :
dc [options]
OPTIONS:
Options |
Description |
-c |
Used for compilation alone. |
-l |
Start up the scale to 20, instead with the default zero. Explains the Math Functions. |
filename |
Not an important command. Calculates the file name of the basic calculator command. |
EXAMPLE:
- Multiplication operation using dc command
echo '3 4 * p' | dc
Output:
12
The above command is used for mathematical calculations.
- Additional operation using dc command
echo '3 4 + p' | dc
Output:
7
The above command displays the sum of '3+4'.
- Mathmatical operation from text file
dc calc.txt
Output:
12
'calc.txt' file have the following code:8 4 + p. Get the input from file and displays the output.