ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
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.
I) I wrote a programm which validates a password given to it as the first argument. The password must be of minimal length 8, it must contain at least 2 numerical and two non-alphanumerical characters.
The problem occurs when i want to include two $ signs in the password, for example...password : validate_password.sh abc$$123.
Echo or printf return: abc4534123.The dollar signs are changed. I found out that if i put the password in single quotes it works fine.
The problem is, that i dont want it to be in single quotes.
Is there a switch for disabling the interpretation of the $ sign?
II) I wrote a program that prints out the latest modified file. I used "ls -lrt". My question is...can i somehow give ls a specific directory (for example: /user/etc)so ls will (recursively)list only its content?
The directory would be given to the program as the first argument.
See below for an idea of what i mean...
directory=${1}
ls -lrt ${1} ...do stuff only for the files returned by ls.
I) I wrote a programm which validates a password given to it as the first argument. The password must be of minimal length 8, it must contain at least 2 numerical and two non-alphanumerical characters.
The problem occurs when i want to include two $ signs in the password, for example...password : validate_password.sh abc$$123.
Echo or printf return: abc4534123.The dollar signs are changed. I found out that if i put the password in single quotes it works fine.
The problem is, that i dont want it to be in single quotes.
Is there a switch for disabling the interpretation of the $ sign?
No but there is almost certainly a way to do what you want. When you write "i dont want it to be in single quotes", where don't you want it to be in single quotes? On the command line to your script? If you want the shell to ignore $ there then you must either put it in single quotes or "escape" it like abc\$\$123
II) I wrote a program that prints out the latest modified file. I used "ls -lrt". My question is...can i somehow give ls a specific directory (for example: /user/etc)so ls will (recursively)list only its content?
The directory would be given to the program as the first argument.
See below for an idea of what i mean...
directory=${1}
ls -lrt ${1} ...do stuff only for the files returned by ls.
Better to ask only one question per thread -- it gets confusing when two questions are answered in the same thread.
Yes, i dont want to put my password in single quotes in the terminal, when i call the program, because the program is written for a user, who would not know, that he/she must put his password in single quotes. So the user would simply type ....validate_password.sh abc$$$123 ,without the password being in quotes.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.