How can I declare and use Boolean variables in a shell script?

Revised Answer (Feb 12, 2014) Original Answer Caveats: https://stackoverflow.com/a/21210966/89391 From: Using boolean variables in Bash The reason the original answer is included here is because the comments before the revision on Feb 12, 2014 pertain only to the original answer, and many of the comments are wrong when associated with the revised answer. For example, Dennis Williamson’s … Read more

“while :” vs. “while true” [duplicate]

from manual: : [arguments] No effect; the command does nothing beyond expanding arguments and performing any specified redirections. A zero exit code is returned. As this returns always zero therefore is is similar to be used as true Check out this answer: What Is the Purpose of the `:’ (colon) GNU Bash Builtin?

An “and” operator for an “if” statement in Bash

What you have should work, unless ${STATUS} is empty. It would probably be better to do: or It’s hard to say, since you haven’t shown us exactly what is going wrong with your script. Personal opinion: never use [[. It suppresses important error messages and is not portable to different shells.

Passing parameters to a Bash function

There are two typical ways of declaring a function. I prefer the second approach. or To call a function with arguments: The function refers to passed arguments by their position (not by name), that is $1, $2, and so forth. $0 is the name of the script itself. Example: Also, you need to call your function after it is declared. Output: … Read more

‘\r’: command not found – .bashrc / .bash_profile [duplicate]

When all else fails in Cygwin… Try running the dos2unix command on the file in question. It might help when you see error messages like this: -bash: ‘\r’: command not found Windows style newline characters can cause issues in Cygwin. The dos2unix command modifies newline characters so they are Unix / Cygwin compatible. CAUTION: the dos2unix command modifies files in place, … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)