-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgsl
executable file
·36 lines (27 loc) · 891 Bytes
/
gsl
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
#!/usr/bin/env bash
# debugging switches
# set -o errexit # abort on nonzero exitstatus; same as set -e
# set -o nounset # abort on unbound variable; same as set -u
set -o pipefail # don't hide errors within pipes
# set -o xtrace # show commands being executed; same as set -x
# set -o verbose # verbose mode; same as set -v
source /srv/timbos-hn-reader/functions.sh
source /srv/timbos-hn-reader/thnr-common-functions.sh
day="$1"
keyword="$2"
shift
shift
cur_year=$(date +"%Y")
if [[ $# -eq 0 ]]; then
echo "gsl: (G)rep (S)pecific (L)ogfile"
echo "Usage: gsl <day> <keyword>"
echo "Example: gsl 066 unexpected"
exit 1
fi
logfile="/srv/timbos-hn-reader/logs/thnr-combined-${cur_year}-${day}.log"
printf "${logfile}\n"
if [[ -f "${logfile}" ]]; then
grep --color --perl-regexp --text "${keyword}" "$@" "${logfile}"
else
echo "${logfile} not found"
fi