rjw | 1f88458 | 2022-01-06 17:20:42 +0800 | [diff] [blame^] | 1 | #!/bin/bash |
2 | |||||
3 | FILE_PATH=$1 | ||||
4 | ALIGNMENT=$2 | ||||
5 | PADDING_SIZE=0 | ||||
6 | |||||
7 | FILE_SIZE=$(($(wc -c < "${FILE_PATH}"))) | ||||
8 | REMAINDER=$((${FILE_SIZE} % ${ALIGNMENT})) | ||||
9 | FILE_DIR=$(dirname "${FILE_PATH}") | ||||
10 | if [ ${REMAINDER} -ne 0 ]; then | ||||
11 | PADDING_SIZE=$((${ALIGNMENT} - ${REMAINDER})) | ||||
12 | dd if=/dev/zero of=${FILE_DIR}/padding.txt bs=$PADDING_SIZE count=1 | ||||
13 | cat ${FILE_DIR}/padding.txt>>${FILE_PATH} | ||||
14 | rm ${FILE_DIR}/padding.txt | ||||
15 | fi |