Linux - GeneralThis Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then 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.
Doing "--host=localhost" is unnecessary unless you've got multiple requirements for this script so that it can take in options other than the hostname.
You can just do: myscript.sh localhost
Anything passed at the command line becomes a positional variable starting at 1. So the above is sending a variable called $1 into your script.
Since positional parameters can actually be changed depending on what you are doing the first thing you'd want to do in the script is store what was passed in into another variable that doesn't change:
From then on you could get "localhost" by referencing $HOST.
You can do more than one variable the way I wrote it. The second one would be $2, the third would be $3 etc...
Creating options flags would be something you'd do if you want to have different choices each time. (e.g. --host to specify host or --user to specify user and invocations where you intend to sometimes specify ONLY the user or ONLY the host. If you're specifying both user and host every time then doing it without the --host and --user would be the way to go).