Shell Scripting: How to Automate Command Line Tasks Using Bash Scripting and Shell Programming
Rate it:
Open Preview
Kindle Notes & Highlights
19%
Flag icon
You can access all the positional parameters starting at $1 to the very last one on the command line by using the special variable $@.
28%
Flag icon
The special variable $? contains the return code of the previously executed command.
31%
Flag icon
The command following a double pipe will only execute if the previous command fails.  If the first command returns a non-zero exit status, then the next command is executed.
39%
Flag icon
Note that it's a best practice to place all of your functions at the top of your script.  This ensures they are all defined before they are used.
41%
Flag icon
If a global variable is defined in a function, it is not available outside that function until the function is called and executed.
42%
Flag icon
Use the local keyword before the variable name.  Only use the local keyword the first time the local variable is used.  Note that the local keyword can only be used inside a function.
44%
Flag icon
The special variable $$ represents the PID of the currently running shell script.