Work the Shell - Solve: a Command-Line Calculator
Dave Taylor has been hacking shell scripts for over thirty years. Really. He's the author of the popular "Wicked Cool Shell Scripts" and can be found on Twitter as @DaveTaylor and more generally at www.DaveTaylorOnline.com.
Today’s modular x86 servers are compute-centric, designed as a least common denominator to support a wide range of IT workloads. Those generic, virtualized IT workloads have much different resource optimization requirements than hyperscale and cloud applications. They have resulted in a “one size fits all” enterprise IT architecture that is not optimized for a specific set of IT workloads, and especially not emerging hyperscale workloads, such as web applications, big data, and object storage. In this report, you will learn how shifting the focus from traditional compute-centric IT architectures to an innovative disaggregated fabric-based architecture can optimize and scale your data center.
Sponsored by AMD
Built-in forensics, incident response, and security with Red Hat Enterprise Linux 6
Every security policy provides guidance and requirements for ensuring adequate protection of information and data, as well as high-level technical and administrative security requirements for a system in a given environment. Traditionally, providing security for a system focuses on the confidentiality of the information on it. However, protecting the data integrity and system and data availability is just as important. For example, when processing United States intelligence information, there are three attributes that require protection: confidentiality, integrity, and availability.
Learn more about catching the bad guy in this free white paper.
Sponsored by DLT Solutions
| Making Linux and Android Get Along (It's Not as Hard as It Sounds) | May 16, 2013 |
| Drupal Is a Framework: Why Everyone Needs to Understand This | May 15, 2013 |
| Home, My Backup Data Center | May 13, 2013 |
| Non-Linux FOSS: Seashore | May 10, 2013 |
| Trying to Tame the Tablet | May 08, 2013 |
| Dart: a New Web Programming Experience | May 07, 2013 |
- New Products
- RSS Feeds
- Making Linux and Android Get Along (It's Not as Hard as It Sounds)
- A Topic for Discussion - Open Source Feature-Richness?
- Drupal Is a Framework: Why Everyone Needs to Understand This
- Home, My Backup Data Center
- Python Programming for Beginners
- New Products
- New Products
- New Products
- Hey God - You may not be
3 hours 7 min ago - Reply to comment | Linux Journal
5 hours 40 min ago - Drupal is an Awesome CMS and a Crappy development framework
10 hours 19 min ago - IT industry leaders
12 hours 42 min ago - Reply to comment | Linux Journal
1 day 5 hours ago - Reply to comment | Linux Journal
1 day 8 hours ago - Reply to comment | Linux Journal
1 day 9 hours ago - great post
1 day 9 hours ago - Google Docs
1 day 10 hours ago - Reply to comment | Linux Journal
1 day 15 hours ago
Enter to Win an Adafruit Prototyping Pi Plate Kit for Raspberry Pi

It's Raspberry Pi month at Linux Journal. Each week in May, Adafruit will be giving away a Pi-related prize to a lucky, randomly drawn LJ reader. Winners will be announced weekly.
Fill out the fields below to enter to win this week's prize-- a Prototyping Pi Plate Kit for Raspberry Pi.
Congratulations to our winners so far:
- 5-8-13, Pi Starter Pack: Jack Davis
- 5-15-13, Pi Model B 512MB RAM: Patrick Dunn
- Next winner announced on 5-21-13!
Free Webinar: Linux Backup and Recovery
Most companies incorporate backup procedures for critical data, which can be restored quickly if a loss occurs. However, fewer companies are prepared for catastrophic system failures, in which they lose all data, the entire operating system, applications, settings, patches and more, reducing their system(s) to “bare metal.” After all, before data can be restored to a system, there must be a system to restore it to.
In this one hour webinar, learn how to enhance your existing backup strategies for better disaster recovery preparedness using Storix System Backup Administrator (SBAdmin), a highly flexible bare-metal recovery solution for UNIX and Linux systems.




Comments
dc Works!
So, your gripe with dc is that you can't do what, exactly? Expect it to evaluate expressions in your format when it clearly is expecting RPN? That's basically equivalent to someone sending you an exe file- "everyone uses it, you should be able to as well".
As far as not evaluating the expression on the command line, you can alias 'dc -e' to 'solve' or whatever. The only flaw with this method is that you must enclose your expression in quotes if it has spaces, but a Linux user should really be able to figure this out on his own. If you want to see 10 decimals of accuracy, make your alias 'dc -e 10k -e'. Read the manpage; you should see how to add constants such as pi and e in as register values.
Better way: CLAC
Since the time of this article, a better alternative to bc/dc has emerged.
The clac (Command Line Advanced Calculator) utility evaluates mathematical expressions from the argument list or from stdin and writes the answer(s) to stdout.
Unlike other command line calculators, clac has infix (natural order) expression syntax, is quite comfortable with complex numbers, defines a great many functions and constants by default, and allows easy definition of new user functions and constants using Python.
If it is not already in your favorite distro's repository, you can download and run it easily. All it needs is python.
thanks but ...
if u need decimal point numbers how about doing
bc -l
??
"With this kind of burnout
"With this kind of burnout on a rudimentary math task..."
Wow. Maybe the burnout is the user, not the tool.
Once there are more than two operations and 3 number, I find the RPN is much easier to use and debug.
And no wrapper is needed. :)
RPN
Actually, I like dc. I use it for all sorts of things. It is nice for my checkbook and expense journal because all numbers are left on the screen for visual double checking. I also like the hundreds of digits capacity, for the fun of it. I suppose part of the difference is I understand RPN, heh, heh.
Also, my Linux machine has dosemu, which means I can run Qbasic if I need more complex calculations. I used an early HP-25 with RPN in the 70's. My HP-20S, which does not use RPN, worked great for impedance calculations on black boxes for the B-2 before I retired in 1997. It needs new batteries.
Friends in Mexico had no idea what I meant by a slide rule, and I bumped into my old one in my filing cabinet, I will be taking it with me Friday when I go there, to show them what one is. A real relic, yes?
cool thanks!
cool thanks!
I always use this great
I always use this great Command Line Calculator
http://www.fnoware.st/?CLC-linux
a windows version does also exists
excellent post, based on it
excellent post, based on it I was able to add this to a function (or alias) too
#
# foo(){echo "scale=4;$@" | bc -l; }
#
# alias bar='bash -c '\''echo "scale=4;$0 $@" | bc -l '\'''
#
thank you.
Cool tip
thanks for the tip. I have spent a good amount of time before reading the bc man and looking into other ways to do this. Thanks alot.