Skip to content

Latest commit

 

History

History
42 lines (28 loc) · 1.24 KB

bash.md

File metadata and controls

42 lines (28 loc) · 1.24 KB

bash

Books

Command combination operator

[[ -f "/spoon" ]] || { echo "There is no spoon" ; exit 1; }

Here Documents

Examples

The format of here-documents is:

  <<[-]word
	  here-document
  delimiter

If word is unquoted, all lines of the here-document are subjected to parameter expansion, command substitution, and arithmetic expansion. In the latter case, the character sequence <newline> is ignored, and \ must be used to quote the characters , $, and `.

If the redirection operator is <<-, then all leading tab characters are stripped from input lines and the line containing delimiter. This allows here-documents within shell scripts to be indented in a natural fashion.

Run on exit (trap)

Wiki

cleanup() {
  echo 'cleanup'
}

trap 'cleanup' EXIT