fbpx

BASH Cheat Sheet With StackOverflow References

If statements

https://ryanstutorials.net/bash-scripting-tutorial/bash-if-statements.php

How to output the date

https://www.shell-tips.com/linux/how-to-format-date-and-time-in-linux-macos-and-bash/

Calculate time differences

https://stackoverflow.com/questions/8903239/how-to-calculate-time-elapsed-in-bash-script

Source a file in the same directory

https://unix.stackexchange.com/questions/17717/refer-to-a-file-under-the-same-directory-of-a-script-found-in-path

Truthy / falsy (boolean) values

https://stackoverflow.com/questions/2953646/how-can-i-declare-and-use-boolean-variables-in-a-shell-script

Can you nest if statements in Bash?

4 Bash If Statement Examples ( If then fi, If then else fi, If elif else fi, Nested if )

Typical error:

line 44: [: =: unary operator expected

Bash Unary Operator Expected: What Does It Mean?

how to see in bash if a variable is set

https://www.cyberciti.biz/faq/see-check-if-bash-variable-defined-in-script-on-linux-unix-macos/

Output hostname in Bash

$HOSTNAME

Getting Hostname in Bash in Linux

How to concat variable in Bash

https://stackoverflow.com/questions/4181703/how-to-concatenate-string-variables-in-bash

A Bash function with variables

#!/bin/bash

greeting () {
   echo "Hello $1"
}

greeting "Joe"

That was fun!

Share this article

Share on facebook
Share on twitter
Share on linkedin

Leave a Reply

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

Scroll to Top