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.
Notices
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.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Thus, the email script greps for the id number (0 to 4) and them awks for the email address.
However, sometimes the grep command will get multiple lines, for example, grepping for "0" will return:
0 Mark x@aastudios.co.uk
4 Gary bu2004@akrepro.co.uk
this will then not work for the emailing because the awk will get two lines instead of just one.
Let us assume that we are in the situation as above, where I have to send an email to id number 4, Gary, however, my grep has given me two lines.
Alternatively, put some character in front of the user number that is not valid for an email address (such as a #, for instance) then test for "#0" instead of testing for merely "0"
You would probably just use '4' as the argument for $2. Unless what you are saying is that you want to have arbitrary argument/value pairs as arguments. If that were the case, you would need to either analyse the argument $1 to determine the argument and value values, or precede the command with variable=value.
If you use:
variable=value command arguments
then you are setting the value of $variable before executing the command. This is commonly done with ./configure scripts or make commands to change defaults. You might want to read the 'info bash' pages at variable expansion. For example you might use something like: ${PARAMETER:+WORD}, or have a test for the value before setting a default.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.