aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/%HOME%/.bash_utils
diff options
context:
space:
mode:
authorEgor Tensin <Egor.Tensin@gmail.com>2018-08-01 19:05:13 +0300
committerEgor Tensin <Egor.Tensin@gmail.com>2018-08-01 19:05:13 +0300
commit41b4b466052f65ea29e9a7b97c19a921b395d536 (patch)
tree72ff6b1cf4a72f87755b76eeb1c0b3dab97ca5ce /%HOME%/.bash_utils
parent.bashrc: fix ssh inside screen (diff)
downloadlinux-home-41b4b466052f65ea29e9a7b97c19a921b395d536.tar.gz
linux-home-41b4b466052f65ea29e9a7b97c19a921b395d536.zip
add str_grep, str_grep_word
Diffstat (limited to '%HOME%/.bash_utils')
-rw-r--r--%HOME%/.bash_utils/text.sh26
1 files changed, 26 insertions, 0 deletions
diff --git a/%HOME%/.bash_utils/text.sh b/%HOME%/.bash_utils/text.sh
index e72167f..da21b5c 100644
--- a/%HOME%/.bash_utils/text.sh
+++ b/%HOME%/.bash_utils/text.sh
@@ -265,3 +265,29 @@ str_join() (
done
echo
)
+
+str_grep() (
+ set -o errexit -o nounset -o pipefail
+
+ if [ "$#" -ne 1 ]; then
+ echo "usage: ${FUNCNAME[0]} PATTERN" >&2
+ return 1
+ fi
+
+ local pattern="$1"
+
+ find . -type f -exec grep --fixed-strings --binary-files=without-match --regexp="$pattern" -- {} +
+)
+
+str_grep_word() (
+ set -o errexit -o nounset -o pipefail
+
+ if [ "$#" -ne 1 ]; then
+ echo "usage: ${FUNCNAME[0]} PATTERN" >&2
+ return 1
+ fi
+
+ local pattern="$1"
+
+ find . -type f -exec grep --basic-regexp --binary-files=without-match --regexp="\b$pattern\b" -- {} +
+)