Bash
Better Bash Scripting
Better Scripting
To improve shell scripts there are things we can do in Bash that we don't have to call on an external command to do (expr, sed, etc.).
Use $(...) for Process Substitution rather than:
`...`
as it scans more easily and you can nest them trivially.
- Use $(( 1+1 )) for Arithmetic rather than calling out to expr with its very inflexible syntax.
- Use Parameter Expansion to manipulate strings (basename, dirname, filename extensions, etc.)
- Use Arrays.
- Handle Errors automatically.
Help Required
- Debugging Bash.
Shell Tricks
- Use the shell to determine if certain files exist rather than wait for a command to fail.
- Redirect stdout and stderr independently and to a file.
Document Actions