aboutsummaryrefslogtreecommitdiff
path: root/bin/rgl
blob: 03f1ba717c4eb647384d6f9d83da13e32ea7f56f (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#!/bin/sh
# Read grep(1) patterns from input and search for them in the given files

# Check the arguments
if [ "$#" -eq 0 ] ; then
    printf >&2 'rgl: Need at least one filename\n'
    exit 2
fi

# Iterate over the patterns and search for each one; if the input is a terminal
# include a slash prompt for the next pattern
while { 
    [ -t 0 ] && printf /
    read -r pat
} ; do
    grep -- "$pat" "$@"
done