Created
January 25, 2024 21:47
-
-
Save leogdion/ba9bb09f7acc4a374b3bddd8e2ca20b4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
SOURCE_DIR="/path/to/your/source/directory" | |
find "$SOURCE_DIR" -name "*.swift" -type f -print0 | while IFS= read -r -d '' file; do | |
# Create a temporary file for editing | |
tmp_file=$(mktemp) | |
# Use awk to perform the replacement and save to the temporary file | |
awk ' | |
BEGIN { in_block = 0; } | |
/\/\*\*/ { in_block = 1; print "/// A struct representing an Atom category."; next; } | |
/\*\// { in_block = 0; print "/// - SeeAlso: `EntryCategory`"; next; } | |
{ if (in_block) { gsub(/^ \*/, "/// "); print "///" $0; } else { print; } } | |
' "$file" > "$tmp_file" | |
# Overwrite the original file with the temporary file | |
mv "$tmp_file" "$file" | |
echo "Updated: $file" | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment