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

“sed” command in bash

sed is the Stream EDitor. It can do a whole pile of really cool things, but the most common is text replacement. The s,%,$,g part of the command line is the sed command to execute. The s stands for substitute, the , characters are delimiters (other characters can be used; /, : and @ are popular). The % is the pattern to match (here a literal percent sign) and the $ is the second pattern … Read more

What does “-ne” mean in bash?

This is one of those things that can be difficult to search for if you don’t already know where to look. [ is actually a command, not part of the bash shell syntax as you might expect. It happens to be a Bash built-in command, so it’s documented in the Bash manual. There’s also an external … Read more

“unary operator expected” error in Bash if condition

If you know you’re always going to use Bash, it’s much easier to always use the double bracket conditional compound command [[ … ]], instead of the POSIX-compatible single bracket version [ … ]. Inside a [[ … ]] compound, word-splitting and pathname expansion are not applied to words, so you can rely on to compare the value of $aug1 with … Read more

Curl command for https ( SSL )

if you’re using a self signed certificate on the server, you can use: but be aware that then it’s no better than using non SSL connection to the server, as your communication won’t be secure anymore, enabling all sorts of man in the middle attacks. Though my advice to you is to download the .pem from the … Read more