diff options
author | Egor Tensin <Egor.Tensin@gmail.com> | 2016-11-22 03:30:34 +0300 |
---|---|---|
committer | Egor Tensin <Egor.Tensin@gmail.com> | 2016-11-22 03:30:34 +0300 |
commit | d6b210f044b5ad6866170bdb77d5702c5db1b76a (patch) | |
tree | 75b359e18e728fdedc6f65b01d43dda7749c50f3 | |
parent | refactoring (diff) | |
download | linux-home-d6b210f044b5ad6866170bdb77d5702c5db1b76a.tar.gz linux-home-d6b210f044b5ad6866170bdb77d5702c5db1b76a.zip |
add str_invert_match
Diffstat (limited to '')
-rw-r--r-- | %HOME%/.bash_utils/text.sh | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/%HOME%/.bash_utils/text.sh b/%HOME%/.bash_utils/text.sh index 88118f9..144bc2c 100644 --- a/%HOME%/.bash_utils/text.sh +++ b/%HOME%/.bash_utils/text.sh @@ -184,3 +184,21 @@ str_join() ( ;; esac ) + +str_invert_match() ( + set -o errexit -o nounset -o pipefail + + local -a pattern_list=() + + local pattern + for pattern; do + pattern_list+=('-e' "$pattern") + done + + if [ "${#pattern_list[@]}" -eq 0 ]; then + cat + else + grep --fixed-strings --invert-match \ + ${pattern_list[@]+"${pattern_list[@]}"} + fi +) |