-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathfindhere.sh
27 lines (22 loc) · 923 Bytes
/
findhere.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#!/bin/bash
searchString=$1
searchSuffix=$2
additionalString=$3
if [ "$1" = "-h" ] || [ "$1" = "--help" ]; then
echo "-h or --help : print help message"
echo " usage: ./script keyword1 "
echo " usage: ./script keyword1 suffix "
echo " usage: ./script keyword1 "" keyword2 "
echo " usage: ./script keyword1 suffix keyword2 "
echo " keyword1 = red and keyword2 = blue color"
elif [ -z "$additionalString" ]; then
# usage: ./script keyword1
find . -iname "*${searchString}*${searchSuffix}" 2>/dev/null | \
grep -i --color=always ${searchString}
else
# usage: ./script keyword1 suffix keyword2
# usage" ./script keyword1 "" keyword2 ( just search keyword1 and keyword2 )
find . -iname "*${searchString}*${searchSuffix}" 2>/dev/null | \
grep -i --color=always ${searchString} | \
GREP_COLORS="mt=01;34" grep -i ${additionalString}
fi