-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patharchive-search.sh
44 lines (36 loc) · 1.06 KB
/
archive-search.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
#!/bin/bash
echo "Archive Searcher"
###Declare main variables
SRCHSTRG=$(dialog --title "Enter search string" --inputbox 1 16);
SAVEAS=$(dialog --title "Output save location" --fselect /~ 14 48);
STRTDATE=$(dialog --title "Start Date" --calendar);
ENDDATE=$(dialog --title "End Date" --calendar);
###Declare truncated variables
STRTDY=$(cut -c 1-2 $STRTDATE);
ENDDY=$(cut -c 1-2 $ENDDATE);
STRTMO=$(cut -c 4-5 $STRTDATE);
ENDMO=$(cut -c 4-5 $ENDDATE);
STRTYR=$(cut -c 7-8 $STRTDATE);
ENDYR=$(cut -c 7-8 $ENDDATE);
###Declare functions
search()
{
for(i=$1;i<=$2;i++)
{
nice -5 zgrep "$SRCHSTRG" /home/BroLogs/$i* | cf >> $SAVEAS &
echo "Now searching" $i ###Replace with dialog info box
}
}
###Execute functions baesed on IF-statements. Incomplete ATM.
if ($STRTDAY != $ENDDAY)
search $STRTDY $ENDDY
$STRTDAY=$STRTDAY+1
if ($STRTMO != $ENDMO)
search $STRTMO $ENDMO
####continue####
if ($STRTYR != $ENDYR)
search $STRTYR $ENDYR
#####continue####
###Output
clear
echo "Search complete!"\n"Your results can be viewed from the following location:" $SAVEAS