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.
@szboardstretcher: I am trying to set the variables and the value of these variables will be used as final result of this script
@HMW: Yes, i was wrong. I corrected in the script.
@shadow 7: Not aware that $() and `` does the same thing. I thought the commands enclosed in `` will be executed first and this can be enclosed in $() too. Please correct me if i am wrong. As far as the variables are concerned, i would like to keep it local to the script. But i am working on specific part of the script.
This portion of the script should give output as DB1=DB001, and DB2=DB002 (obviously, as per the inputs given in the script) But i have a doubt on setting the variable name itself. "DBN$j" is this the right bash variable name?
./test1: line 31: DBN2: command not found
./test1: line 31: DBN3: command not found
./test1: line 31: DBN4: command not found
./test1: line 31: DBN5: command not found
./test1: line 31: DBN6: command not found
./test1: line 31: DBN7: command not found
./test1: line 31: DBN8: command not found
./test1: line 31: DBN9: command not found
./test1: line 31: DBN10: command not found
I thought the commands enclosed in `` will be executed first and this can be enclosed in $() too.
There is not set precedence except for the fact the shell will expand all items working from the inside out. The main advantage of $(), apart from being clearer IMO, is that they can be nested.
So you can do $(cmd1 $(cmd2)), but `cmd1 `cmd2`` will fail
As for your code, I would perhaps looking at doing most of it with just bash as the calls to outside commands like awk and sed are not really needed.
So I have commented out your original pieces and put in what I would have done: