A normal if statement in bash looks like this

Here is how to make it one line

And here is how to make it one line with ampersands ands and pipe ors

Finally. I think its important to take back the format of these if statements

Also you will probably note that its important to know the exit status of your various programs. You will find that most programs have exit statuses that are logical. For example grep returns not 0 when it doesnt find something, and 0 for success when it does find something. Also the most common operation with if is the test program which has very logical exit statuses. Test can be run with the command “test test-statement” or “[ test-statement ]”. More reading here: http://tldp.org/LDP/Bash-Beginners-Guide/html/sect_07_01.html


Leave a Reply

Your email address will not be published. Required fields are marked *