Skip to content

Instantly share code, notes, and snippets.

@heartshare
Forked from benjamincrozat/concat.sh
Created September 6, 2024 23:06
Show Gist options
  • Save heartshare/c9e54736358add4b369457ccdc9a09dc to your computer and use it in GitHub Desktop.
Save heartshare/c9e54736358add4b369457ccdc9a09dc to your computer and use it in GitHub Desktop.
#!/bin/bash
# Define the output file
output_file="combined.md"
# Remove the output file if it exists to avoid including it in the search
if [ -f "$output_file" ]; then
rm "$output_file"
fi
# Find all Markdown files in subfolders, exclude the output file path, and concatenate them into one file
find . -type f -name '*.md' ! -path "./$output_file" -exec echo "Adding {} to $output_file" \; -exec cat {} + >> $output_file
echo "All Markdown files have been concatenated into $output_file"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment