Adds multigrep script
This commit is contained in:
parent
a550d3f640
commit
ce49677a3e
1 changed files with 24 additions and 0 deletions
24
bin/.bin/multigrep
Executable file
24
bin/.bin/multigrep
Executable file
|
@ -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…
Add table
Add a link
Reference in a new issue