Adds multigrep script

master
Jonathan Hodgson 5 years ago
parent 579c885521
commit 88d4c56f3e
  1. 24
      bin/.bin/multigrep

@ -0,0 +1,24 @@
#!/usr/bin/env bash
# will grep for each argument passed
# Can pass each search arguments by adding an argument before in the form
# --args="-i -E" or --args "-i -E"
if [ -n "$1" ]; then
args=""
if [[ "$1" == "--args" ]]; then
args=( $2 )
shift
shift
elif [[ "$1" == "--args="* ]]; then
tmp="${1#--args=}"
args=( $tmp )
shift
fi
i="$1"
shift
cat - | grep ${args[@]} "$i" | multigrep "$@"
else
cat -
fi
Loading…
Cancel
Save