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.
It depends on what your shell is and how it's configured.
If you are running bash, it doesn't matter because it doesn't really look at the first line (one of bash oddities). So this works on a lot of default install. It works on my machine.
If you are running another one like "dash" then it will look at the first line (shebang).
that's what my next line says ..... depends on which shell you use.
Note that (for those who don't know) on Linux sh is often symlinked to bash, but that won't always happen.
In production environments, you should ALWAYS specify the shell to be used, just in case the SW is installed under a user whose default shell turns out to be different.
I could be wrong, but I think that's only true if a cmd shell is NOT specifed as the first line.
Otherwise, i think the parent shell (or kernel?) will try to use the shell specified ...
Actually, that happened today at work.
Tried to run a script that specified #!/bin/ksh, but it turned out that the local version was in /usr/bin/ksh
You can explicitely tell what shell to use, as in:
Else the shell used will be the one told on the first line. As said above, on Linux, /bin/sh is often an alias for /bin/bash; however /bin/bash, when called as sh, changes its inner workings to be closer to the behaviour of the old original sh.
In your case, $((...)) is a bash-only feature, hence the problem you had. However this line can be "standardized" with the expr command.
You're right wjevans! The man page changed since I read about this issue back in the early '90. Now it reads like this:
<<When invoked as sh, bash enters posix mode after the startup files are read.>>
and I suppose $((...)) is posix. I stand corrected.