-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfileParser
More file actions
40 lines (31 loc) · 965 Bytes
/
fileParser
File metadata and controls
40 lines (31 loc) · 965 Bytes
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
#!/bin/bash
#MANUAL:
# Type <scriptname> <month> <from day> <to day> <year>
# Type ./fileParser <02> <01> <28> <18>
# It can only parse files for a single month
# To parse 2 months, execute script twice then concatenate example:
# cat ech_output1.txt ech_output2.txt > new_output.txt
declare echFiles=(`ls /Volumes/CHRSPLOGS`)
declare readFiles=()
month=$1
from=$2
to=$3
year=$4
folderTarget=""
mkdir ~/Desktop/ech/ > /dev/null 2>&1
touch ~/Desktop/ech/ech_output$month$from$to$year.txt
for (( i=$from; i<=$to; i++ )); do
if [[ i -lt 10 ]]; then
folderTarget=$month
folderTarget+="0"
folderTarget+=$i
folderTarget+=$year
else
folderTarget=$month$i$year
fi
readFiles=(`ls /Volumes/CHRSPLOGS/$folderTarget/`)
for (( a=0; a<${#readFiles[*]}; a++ )); do
cat /Volumes/CHRSPLOGS/$folderTarget/${readFiles[$a]} | grep 72200 >> ~/Desktop/ech/ech_output$month$from$to$year.txt
echo /Volumes/CHRSPLOGS/$folderTarget/${readFiles[$a]}
done
done