-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathbin-graph-all-modes.sh
More file actions
executable file
·52 lines (46 loc) · 2.03 KB
/
bin-graph-all-modes.sh
File metadata and controls
executable file
·52 lines (46 loc) · 2.03 KB
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
#!/usr/bin/env bash
#
# Copyright 2025 8dcc. All Rights Reserved.
#
# This file is part of bin-graph.
#
# This program is free software: you can redistribute it and/or modify it under
# the terms of the GNU General Public License as published by the Free Software
# Foundation, either version 3 of the License, or (at your option) any later
# version.
#
# This program is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
# details.
#
# You should have received a copy of the GNU General Public License along with
# this program. If not, see <https://www.gnu.org/licenses/>.
#
# -----------------------------------------------------------------------------
#
# Simple script for generating multiple binary graphs from the same file.
set -e
BIN_GRAPH='bin-graph'
if [ $# -ne 1 ]; then
echo "Usage: $(basename "$0") INPUT" 1>&2
exit 1
fi
assert_cmd() {
if [ ! "$(command -v "$1")" ]; then
echo "$(basename "$0"): The '$1' command is not installed." 1>&2
exit 1
fi
}
assert_cmd "$BIN_GRAPH"
input_file="${*: -1}"
# Command-line options for each mode.
"$BIN_GRAPH" --mode 'grayscale' "$input_file" "${input_file}.grayscale.png"
"$BIN_GRAPH" --mode 'ascii' "$input_file" "${input_file}.ascii.png"
"$BIN_GRAPH" --mode 'entropy' --transform-squares 16 "$input_file" "${input_file}.entropy.png"
"$BIN_GRAPH" --mode 'histogram' "$input_file" "${input_file}.histogram.png"
"$BIN_GRAPH" --mode 'bigrams' "$input_file" "${input_file}.bigrams.png"
"$BIN_GRAPH" --mode 'dotplot' --offset-start 0 --offset-end 1000 "$input_file" "${input_file}.dotplot1.png"
"$BIN_GRAPH" --mode 'dotplot' --offset-start 4000 --offset-end 5000 "$input_file" "${input_file}.dotplot2.png"
"$BIN_GRAPH" --mode 'dotplot' --offset-start 10000 --offset-end 11000 "$input_file" "${input_file}.dotplot3.png"
"$BIN_GRAPH" --mode 'dotplot' --offset-start 30000 --offset-end 31000 "$input_file" "${input_file}.dotplot4.png"