-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdisplayAll_similar.sh
executable file
·65 lines (56 loc) · 1.52 KB
/
displayAll_similar.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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#!/bin/bash
# ------------------------------------------------------------------
# [DragonStuff] PokeCHIP
# This file displays similarities from a text file.
# ------------------------------------------------------------------
VERSION=0.0.1
SUBJECT=Search_Database_by_query
USAGE="Usage: displayAll_similar.sh -ihv search_query"
# --- Options processing -------------------------------------------
if [ $# == 0 ] ; then
echo $USAGE
exit 1;
fi
while getopts ":i:vh" optname
do
case "$optname" in
"v")
echo "Version $VERSION"
exit 0;
;;
"i")
echo "-i argument: $OPTARG"
;;
"h")
echo $USAGE
exit 0;
;;
"?")
echo "Unknown option $OPTARG"
exit 0;
;;
":")
echo "No argument value for option $OPTARG"
exit 0;
;;
*)
echo "Unknown error while processing options"
exit 0;
;;
esac
done
shift $(($OPTIND - 1))
search_Name=$1
# --- Locks -------------------------------------------------------
LOCK_FILE=/tmp/$SUBJECT.lock
if [ -f "$LOCK_FILE" ]; then
echo "Script is already running"
exit
fi
trap "rm -f $LOCK_FILE" EXIT
touch $LOCK_FILE
# --- Body --------------------------------------------------------
# Searching using search.sh
echo Searching for Pokémon type, name or id similar to: $search_Name
echo Number of similarities: `cat displayAll_Database_PreRendered.txt | grep -c $search_Name`
cat displayAll_Database_PreRendered.txt | grep $search_Name