-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcatscript.bash
71 lines (58 loc) · 1.92 KB
/
catscript.bash
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
66
67
68
69
70
71
# !/bin/bash
PUBLISHED=/anfs/www/html/meters/elec/published
echo $PUBLISHED
echo "{
\"item-metadata\":[
{
\"rel\":\"urn:X-tsbiot:rels:isContentType\",
\"val\":\"application/vnd.tsbiot.catalogue+json\"
},
{
\"rel\":\"urn:X-tsbiot:rels:hasDescription:en\",
\"val\":\"Sensor Data\"
},
{
\"rel\":\"urn:X-tsbiot:rels:supportsSearch\",
\"val\":\"urn:X-tsbiot:search:simple\"
}
],
\"items\":[
" > cat
for meter in $PUBLISHED/*; do
for file in $meter/*; do
if [[ "$(basename $file)" == S-m*-????-??.json ]]; then
newfile=`echo $(basename $file) | cut -d '.' -f 1`
year=`echo $newfile | cut -d '-' -f 3`
month=`echo $newfile | cut -d '-' -f 4`
echo " {
\"href\":\"http://www.cl.cam.ac.uk/meters/elec/published/$(basename $meter)/$(basename $file)\",
\"i-object-metadata\":[
{
\"rel\":\"urn:X-tsbiot:rels:isContentType\",
\"val\":\"application/json\"
},
{
\"rel\":\"urn:X-tsbiot:hasDescription:en\",
\"val\":\"$newfile\"
},
{
\"rel\":\"urn:X-tsbiot:hasParent\",
\"val\":\"$(basename $meter)\"
},
{
\"rel\":\"urn:X-tsbiot:Year\",
\"val\":\"$year\"
},
{
\"rel\":\"urn:X-tsbiot:Month\",
\"val\":\"$month\"
}
]
}," >> cat
echo $(basename $file)
fi
done
done
sed -i '$ s/,$/ /' cat
echo " ]
}" >> text.json