Shell command line hybrid binary calculator

Source: Internet
Author: User
Tags ibase

When you need a simple calculation, you do not want to use the GUI calculator, can be directly calculated under the shell is the best

Checked, there is a thing called BC, the specific use will not repeat, you can run BC, and then go into the calculation, you can echo the past, probably like this

Echo " 1+2 " | BC Echo " ibase=16;1a+1 " | Bc

However, it is not easy to use, the first is to specify the system, so that the entire expression is this type of, for example

Echo " ibase=16;1a*10 " | BC              0x1A0x10

But I think it would be more troublesome to calculate the 0x1a multiplied by 10 in 10.

If you can have a hybrid into the calculator, think of the fact that you can also package a, as long as the expression, and then the non-10 binary numbers are converted to 10, and then pass the processed expression to the BC, it should be OK.

So, wrote a script, put on GitHub, need to visit HTTPS://GITHUB.COM/ZQB-ALL/SMARTBC

After downloading, you need to add executable permissions, and then link to the place where your environment variables are found

Like what

chmod +x smartbcsudoln -S 'pwd'/SMARTBC  /USR/BIN/SMARTBC

or an individual name.

sudo Ln -S 'pwd'/SMARTBC  /USR/BIN/MYBC

And then you can use it, just look at the help.

Smartbc-h

This article links http://www.cnblogs.com/zqb-all/p/6793917.html

Shell command line hybrid binary calculator

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.