Better Bash Scripting
I start every bash script with the following prolog:
#!/bin/bash set -o nounset set -o errexitThis will take care of two very common errors:
- Referencing undefined variables (which default to “”)
- Ignoring failing commands
[…]
Bash has a number of (underappreciated) ways to manipulate strings.
[…]
Some commands expect filenames as parameters so straightforward pipelining does not work. This is where
<()
operator comes in handy as it takes a command and transforms it into something which can be used as a filename.
3 Comments RSS · Twitter
August 23, 2014 10:50 PM
Bug: use /usr/bin/env bash since many (most?) systems have /usr/local/bin/bash not in /bin. Only Linux is weird.