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.
Realizing the promise of Apache® Hadoop® requires the effective deployment of compute, memory, storage and networking to achieve optimal results. With its flexibility and multitude of options, it is easy to over or under provision the server infrastructure, resulting in poor performance and high TCO. Join us for an in depth, technical discussion with industry experts from leading Hadoop and server companies who will provide insights into the key considerations for designing and deploying an optimal Hadoop cluster.
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
| Designing Electronics with Linux | May 22, 2013 |
| Dynamic DNS—an Object Lesson in Problem Solving | May 21, 2013 |
| Using Salt Stack and Vagrant for Drupal Development | May 20, 2013 |
| 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 |
- seo services in india
2 hours 54 min ago - For KDE install kio-mtp
2 hours 55 min ago - Evernote is much more...
4 hours 55 min ago - Reply to comment | Linux Journal
13 hours 40 min ago - Dynamic DNS
14 hours 15 min ago - Reply to comment | Linux Journal
15 hours 13 min ago - Reply to comment | Linux Journal
16 hours 3 min ago - Not free anymore
20 hours 5 min ago - Great
23 hours 52 min ago - Reply to comment | Linux Journal
1 day 53 sec ago
Enter to Win an Adafruit Pi Cobbler Breakout 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 Pi Cobbler Breakout 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
- 5-21-13, Prototyping Pi Plate Kit: Philip Kirby
- Next winner announced on 5-27-13!
Featured Jobs
| Linux Systems Administrator | Houston and Austin, Texas | Host Gator |
| Senior Perl Developer | Austin, Texas | Host Gator |
| Technical Support Rep | Houston and Austin, Texas | Host Gator |
| UX Designer | Austin, Texas | Host Gator |
| Web & UI Developer (JavaScript & j Query) | Austin, Texas | Host Gator |
Free Webinar: Hadoop
How to Build an Optimal Hadoop Cluster to Store and Maintain Unlimited Amounts of Data Using Microservers
Realizing the promise of Apache® Hadoop® requires the effective deployment of compute, memory, storage and networking to achieve optimal results. With its flexibility and multitude of options, it is easy to over or under provision the server infrastructure, resulting in poor performance and high TCO. Join us for an in depth, technical discussion with industry experts from leading Hadoop and server companies who will provide insights into the key considerations for designing and deploying an optimal Hadoop cluster.
Some of key questions to be discussed are:
- What is the “typical” Hadoop cluster and what should be installed on the different machine types?
- Why should you consider the typical workload patterns when making your hardware decisions?
- Are all microservers created equal for Hadoop deployments?
- How do I plan for expansion if I require more compute, memory, storage or networking?




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.