Skip to content

Instantly share code, notes, and snippets.

@Lirt
Lirt / bash-options.sh
Last active March 22, 2017 15:19
Bash specific function and syntax cheatsheet
# Exit on error
set -e
# Exit if variable was not set
set -u
# Exit when command in pipe fails
set -o pipefail
# Print every command executed with variable interpolation
set -x
@Lirt
Lirt / lines-from-pattern.sh
Last active May 4, 2018 11:00
Sed examples
# Print lines from line which match pattern to end of file
pattern=""
sed -n "/$pattern/,$ p" file.txt
# Example
pattern="mnop"
str="$(echo -e "abcd\nefgh\nijkl\nmnop\nqrst\nuvw\nxyz" | sed -n "/$pattern/,$ p")"
echo $str
# Remove lines before line LINE including LINE