#!/usr/bin/env bash # # Script for https://sectordisk.pw # usage: ./mksector.sh in.txt out.dat # # vim -> :set nofixendofline # or # vim -b # :set noeol # :wq # # in.txt should be 16x32 text (~543 bytes) # out.dat should be a 512 byte sector # # SPDX-License-Identifier: MIT if [[ $# -ne 2 ]]; then echo "Usage: $0 " exit 1 fi IN="$1" OUT="$2" if [[ "${IN}" == "${OUT}" ]]; then echo "Input and output files should not be the same name" exit 2 fi # requires GNU sed echo echo "Processing ${IN} to ${OUT}" cat "${IN}" | sed ':a;N;$!ba;s/\n//g' > "${OUT}" _SZ=$(stat -c %B "${OUT}") echo "Bytes: ${_SZ}" echo hexdump -Cv "${OUT}"