🖥️bc
➡️This is a command-line reference manual for commands and command combinations that you don’t use often enough to remember it. This cheatsheet explains the bc command with important options and switches using examples.
3 minute read
▁ ▂ ▃ ▄ ꧁ 🔴☠ COMMANDLINE-KUNGFU WITH CHEATSHEETS ☠🔴꧂▅ ▃ ▂ ▁
# ██████╗ ██████╗
# ██╔══██╗██╔════╝
# ██████╔╝██║
# ██╔══██╗██║
# ██████╔╝╚██████╗
# ╚═════╝ ╚═════╝
# Sorry, something messed up when I pasted this into Twitter. x= should be:
# Also, numround is from num-utils either in your package manager or here: https://suso.suso.org/programs/num-utils/index.phtml …
x=$(bc -l <<<"150*$p*s(($p*2/360)*$i)"|numround)
BC_LINE_LENGTH=0 bc <<<"10^100"
# Print out 10 to the 100th power, but use bc's environment variable BC_LINE_LENGTH=0 to print all on one line instead of wrapping.
# Convert a decimal number to octal, hexadecimal, binary, or anything
bc <<< 'obase=2;1234'
# Explanation: <<< word is here-string syntax, a variant of here-documents.
## Related one-liners
# Convert a decimal number to octal, hexadecimal, binary, or anything
echo 'obase=2;1234' | bc
# Explanation:
# bc is an arbitrary precision calculator language.
# obase defines the conversion base for output numbers, in this example 2 (binary)
# ; is a statement separator in bc
# 1234 is the decimal number to convert
# By piping the command to bc we get 1234 in binary format
# Convert a decimal number to octal, hexadecimal, binary, or anything
echo 'obase=2;1234' | bc
# Explanation:
# bc is an arbitrary precision calculator language.
# obase defines the conversion base for output numbers, in this example 2 (binary)
# ; is a statement separator in bc
# 1234 is the decimal number to convert
# By piping the command to bc we get 1234 in binary format
## Alternative one-liners:
# Convert a decimal number to octal, hexadecimal, binary, or anything
bc <<< 'obase=2;1234'
# Explanation: <<< word is here-string syntax, a variant of here-documents.
# Calculate pi to an arbitrary number of decimal places
bc -l <<< "scale=1000; 4*a(1)"
Cheatsheets are an excellent complement to other information sources like Linux man-pages, Linux help, or How-To’s and tutorials, as they provide compact and easily accessible information. While man-pages and detailed tutorials often contain comprehensive explanations and extensive guides, cheatsheets summarize the most important options forthe command bc in a clear format. This allows users to quickly access the needed information for bc without having to sift through lengthy texts. Especially in stressful situations or for recurring tasks, cheatsheets for bc are a valuable resource to work efficiently and purposefully.
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
█║▌│║█║▌★ KALI ★ PARROT ★ DEBIAN 🔴 PENTESTING ★ HACKING ★ █║▌│║█║▌
██╗ ██╗ ██████╗ ██████╗ ██╗ ██╗███████╗██████╗
████████╗██╔══██╗██╔═══██╗╚██╗██╔╝██╔════╝██╔══██╗
╚██╔═██╔╝██║ ██║██║ ██║ ╚███╔╝ █████╗ ██║ ██║
████████╗██║ ██║██║ ██║ ██╔██╗ ██╔══╝ ██║ ██║
╚██╔═██╔╝██████╔╝╚██████╔╝██╔╝ ██╗███████╗██████╔╝
╚═╝ ╚═╝ ╚═════╝ ╚═════╝ ╚═╝ ╚═╝╚══════╝╚═════╝
█║▌│║█║▌ WITH COMMANDLINE-KUNGFU POWER █║▌│║█║▌
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
Feedback
Was this page helpful?
Glad to hear it! Please tell us how we can improve.
Sorry to hear that. Please tell us how we can improve.