Skip to content

Instantly share code, notes, and snippets.

@bryanmr
Last active March 2, 2019 15:32
Show Gist options
  • Save bryanmr/fbe7cbffe0f2eb0e7a78634b541ef1da to your computer and use it in GitHub Desktop.
Save bryanmr/fbe7cbffe0f2eb0e7a78634b541ef1da to your computer and use it in GitHub Desktop.
A quick awk thing I wrote to strip out dead links for images from Jekyll posts
#!/bin/bash
rm -rf /var/tmp/cleaned_posts
mkdir -p /var/tmp/cleaned_posts
while read -r post ; do
awk '/image:/ { our_image=$2 } /<img class/ { print "![For the Cure of Text](" our_image ")";next } { print $0 }' "$post" > /var/tmp/cleaned_posts/"$post"
done <<< "$(find . -name "*.md")"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment