Skip to content

Instantly share code, notes, and snippets.

@ehzawad
Created March 23, 2024 11:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ehzawad/2a3695d2c9aa12a497ffb28da1706119 to your computer and use it in GitHub Desktop.
Save ehzawad/2a3695d2c9aa12a497ffb28da1706119 to your computer and use it in GitHub Desktop.
#!/bin/bash
merge_md_files() {
for dir in "$1"/*; do
if [ -d "$dir" ]; then
md_files=("$dir"/*.md)
if [ ${#md_files[@]} -gt 1 ]; then
merged_file="$dir/$(basename "$dir").md"
cat "${md_files[@]}" > "$merged_file"
fi
merge_md_files "$dir"
fi
done
}
merge_md_files "."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment