docmachine-containers/utils/docs/build_combined.sh

27 lines
452 B
Bash
Executable file

#!/bin/sh
set -ue
INPUT_DIR="$1"
OUTPUT_FILE="$2"
gx_usage() {
echo "Usage: $0 <input_dir> <output_file>"
echo ""
}
if [ -z "$INPUT_DIR" ]; then
gx_usage
exit 1
fi
if [ -z "$OUTPUT_FILE" ]; then
gx_usage
exit 1
fi
find -L "$INPUT_DIR" -regextype sed \( -regex '.*/[0-9][^/]*\.md' ! -regex '.*/_.*' \) -print0 \
| sort -z \
| xargs -0 -iFILE cat FILE \
| sed -e 's/^\s*----\s*$//' -e 's,\[\](.*/images/,[](./images/,' \
> "$OUTPUT_FILE"