-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathfixup-v3
More file actions
executable file
·17 lines (16 loc) · 812 Bytes
/
fixup-v3
File metadata and controls
executable file
·17 lines (16 loc) · 812 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#!/bin/sh
# usage: ./fixup-v3 all-notes.data all-notes.json
#
# description: converts output given by the jar into readable json
# requires first argument as output of decrypted file
# requires second argument as reslt json
#
# implementation:
# perl: remove null characters
# sed: remove empty lines
# perl: delete control characters between final } and newline
# sed: replace all newline characters with comma
# echo: add '[' to the start of file
# sed: remove all characters before '{' at the start of each line starting from the second line
# sed: remove the comma at the end of the file and replace it with ']'
cat $1 | perl -p -e 's/\0\0../\n/g' | sed '/^$/d' | perl -p -e 's/}(?:.(?!}))+$/}/g' | sed 's/$/,/g' | (/bin/echo -n \[ && cat) | sed '2,$ s/^.{/{/' | sed '$s/.$/]/' | python3 -m json.tool > $2