Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Introduction to Linux - A Hands on Guide
This guide was created as an overview of the Linux Operating System, geared toward new users as an exploration tour and getting started guide, with exercises at the end of each chapter.
For more advanced trainees it can be a desktop reference, and a collection of the base knowledge needed to proceed with system and network administration. This book contains many real life examples derived from the author's experience as a Linux system and network administrator, trainer and consultant. They hope these examples will help you to get a better understanding of the Linux system and that you feel encouraged to try out things on your own.
Click Here to receive this Complete Guide absolutely free.
Leading zeros can be tricky; some tools assume this means an octal num.
As per your experiments, 'expr' ignores leading zeroes, 'let' assumes octal; not sure why (()) comes up with that answer... probably something similar.
The technical downside of expr is that its a separate tool, therefore another process being invoked, so a bit more overhead on your system.
Really it depends on what you are doing and what you can assume is on the system.
older bash's or scripts that may run under bourne shell can not use $(()).
expr and $(()) is limited to integers only.
awk can do math using floats and is not very big by todays standards, and can handle columns of data (text tables)
perl has access to basically the full math library and can process any sort of data, or even network connections and full databases. It also has even better data storage
bc on the otherhand can handle ANY sized number or any scale (number of decimal places) I have used it with numbers that has over a thousand digits.
Really it is just what your needs and what limitations you have.
Actually there are other solutions too. I have image processing scripts using ImageMagick. As I have to have the "convert" command on the system for the script to work, I often use that as I can't be as equally sure bc, awk, or perl, is available for math processing (such as under cgiwin). Its a odd way of doing it but it removes added script dependancies.
Can these commands ie. let and then echo, print floating poiint numbers... NO!! It will convert the resulting number in integer and print it. So I think this is not a preferred way to work with. Instead you can use awk code to print full floating point result.