Computer Hope

Other Pages

Home
Site map
Computer help

Dictionary
News
Q&A
What's new

Tools

E-mail this page
Print Preview
Edit this page



 

Linux / Unix bc command

Quick links

About bc
Syntax
Usage
Examples
Related commands
Linux / Unix main page

About bc

Calculator.

Syntax

bc [-c] [-l] [file]

-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.
file Name of the file that contains the bc commands to be calculated this is not a necessary command.

Usage

L A letter a-z
E An expression: a (mathematical or logical) value, an operand that takes a value, or a combination of operands and operators that evaluates to a value.
S Statement
/* and /* Comment
sqrt ( E ) Square root
length ( E ) Number of significant decimal digits.
scale ( E ) Number of digits right of decimal point.
   
   
   
quit Exits the bc command.

Available Operators

+ - * / % ^
(% is remainder; ^ is power)

++ -- (prefix and postfix; apply to names)

== <= >= != < > = =+ =- =* =/ =% =^

Examples

bc cal.txt = Would result in 3, see below notes.

Within the cal.txt file you could have a simple statement such as:

/* Add the value 1+2 /*
1+2
quit

When running the above command you will receive the results of the cal.txt file. Which in this case would be 3.

Related commands

dc
awk

 

Index

Category:
Linux / Unix

Companies:
Click here

Related Pages:

 

Resolved

Were you able to locate the answer to your questions?

Home - Computer help - Contact - Dictionary - Links
Link to Computer Hope - Bookmark Computer Hope