Linux - SoftwareThis forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.
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.
Same thing, I get nothing. BTW - I don't understand why the variable 'mask' was expanded even though it was in single quotes. I thought single quotes prevent expansion. Anyway...
I don't understand it. When I echo the variables they look perfectly normal. You might notice that when I echo the variables, I put quotes around them. If I try and put quotes around them in the find command I get this:
Just in case you're wondering what I'm trying to do in this script.
If a mask is passed to the script, then I define the switch_str script. If no mask is passed, then the switch_str script remains undefined. That way, I can put this switch_str variable on the find command and it should either perform the name function, or just do nothing as it is blank.
I could make 2 separate find commands and have an if statement to choose one or the other, but I have a bunch of switches and a bunch of find commands to handle. I would prefer one find command and have a bunch of switches that are either active or blank.
So I'm lost.
Any help would be appreciated, Thanks.
That worked great, thanks.
The array-thing is a whole new area of bash programming with which I was not familiar (until now).
I'm sure you're right about the asterisks expanding. I'm not looking for any further answer here (I'm good now), but I must remark that I'm still perplexed as to why the asterisks were expanding. If I echo the variable, it looks normal with no expansion. I can even put the entire find command with the switches and asterisks inside one variable, and it will run properly if I just type that variable at the command prompt. But if I try to just put the switch in a variable, something funny happens.
When you want to get a deeper understanding, you can read man bash (on expansions) and info bash. The general idea is following: there are some expansions that always occur if a string is in specific context.
echo "$mask" -> echo "*2*" (stop, as * is inside "")
echo *2* -> something2
echo $mask -> echo *2* -> something2 (as now * is not inside *)
echo *2* (stops right here)
Another question is argument count..
"a b" is one argument, while a b gets split into two arguments.
@ is an exception in a sense - when used as index it allows "-enclosed string to get expanded to multiple arguments.