Usare il terminale come calcolatrice su Linux con bc

Mattepuffo's logo
Usare il terminale come calcolatrice su Linux con bc

Usare il terminale come calcolatrice su Linux con bc

Ho scoperto un comando che ci permette di eseguire calcoli matematici da terminale su Linux: bc!

Se guardate la pagina man, bc viene descritto come "a language that supports arbitrary precision numbers with interactive execution of statements".

In sostanza, più come un linguaggio di calcolo che come un programma.

Se date bc da terminale, si aprirà una spece di shell su cui eseguire i calcoli:

$ bc
bc 1.06.95
Copyright 1991-1994, 1997, 1998, 2000, 2004, 2006 Free Software Foundation, Inc.
This is free software with ABSOLUTELY NO WARRANTY.
For details type `warranty'.
1+3
4
quit

bc supporta anche calcoli più complessi:

$ bc
bc 1.06.95
Copyright 1991-1994, 1997, 1998, 2000, 2004, 2006 Free Software Foundation, Inc.
This is free software with ABSOLUTELY NO WARRANTY.
For details type `warranty'.
scale=30
10/3
3.333333333333333333333333333333
quit

O anche costrutti come if, while e for.

Dategli un'occhiata, può essere comodo se usate i pc da terminale!

Enjoy!


Condividi

Commentami!