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.
That's because they are commands, not some kind of special expression syntax. So they need spaces between arguments just like any other command.
That's not really true. Actually the if and the double square brackets [[ are shell keywords. You probably refer to the single square bracket [ which is either a shell built-in and an external command (provided by coreutils). Anyway, command or keywords doesn't make so much difference: they all require to be separated by space to let the shell correctly parse them.
Instead, one of the more common mistakes in an if statement is the misuse of the relational operator. If you don't put spaces around the == sign, the shell interprets the whole expression as a single string and it evaluates always as true:
Instead of simply asking others to proofread your script, try to understand what the shell is already telling you:
This means that you didn't type a command properly. And that means that you have to go back through the script and find the incorrect command. Usually it will give you a line number or other hint as to where to look. Check the mentioned location carefully.
In addition, when it also says "unexpected end of file", that generally means you're missing a closing argument of some kind, a quotation mark, an "fi", or similar. It reached the the end of the script without finding the closing character or string.
Unfortunately, the given line numbers in EOF errors may not match the actual location of the mistake. The script will pair up whatever quotation marks it finds, for example, and will only give an error when the last unpaired quotation mark is found. Unmatched quotes can be some of the hardest errors to find.
Now if you've gone though you script with a fine-toothed comb and still can't spot the error, then it's ok to ask others to help you. But you should at least make some effort to debug it yourself first.
As you should already know, the single quotes are special characters used by the shell to protect strings from shell expansion. If you want to protect the single quote itself, you can either enclose it in double quotes or escape it using bacslashes. In the first case your assignment would be:
Use always double quotes when you evaluate the variable:
select * from vendor_table where region in ("$ActualRegion")