cheatsheet
Example
#!/bin/bash
NAME="Payam"
echo "Hello $NAME!"
exit 0Variables:
varname=value # defines a variable
varname=value command # defines a variable to be in the environment of a particular subprocess
echo $varname # checks a variable's value
read <varname> # reads a string from the input and assigns it to a variable
let <varname> = <equation> # performs mathematical calculation using operators like +, -, *, /, %
export VARNAME=value # defines an environment variable (will be available in subprocesses)#Special shell variables
echo $$ # prints process ID of the current shell
echo $! # prints process ID of the most recently invoked background job
echo $? # displays the exit status of the last command
echo $0 # display Filename of the shell scriptQuoting:
Redirection
Brace expansion
Parameter expansions
Basics
Substitution
Length
Default Values
Comment
Substrings
Manipulations
Conditionals:
Test Operators
Checking Numbers
Checking Strings
Checking files
More conditions:
if statement:
Loops:
for:
while:
Until:
Case:
Functions:
Arrays
Dictionaries:
Debugging
Miscellaneous:
Last updated