Skip to content

Instantly share code, notes, and snippets.

@nathanleclaire
Last active August 29, 2015 14:11
Show Gist options
  • Save nathanleclaire/678504b7fa7de796b299 to your computer and use it in GitHub Desktop.
Save nathanleclaire/678504b7fa7de796b299 to your computer and use it in GitHub Desktop.

To correct the date format for permalinks:

find -type f -exec sed -i 's/\([0-9]\+-[0-9]\+-[0-9]\+\).*$/"\1"/' {} \;

To replace the {%img ... %} macro from Jekyll:

find -type f -exec sed -i 's/{% *img \([^ ]*\) \(.*\) %}/{{%img src="\1" caption="\2" }}/' {} \;

To convert all tabs to 4 spaces:

find -type f -exec sed -i $'s/\t/    /g' {} \;

To get rid of {% raw %} ... {% endraw %} blocks:

find -type f -exec sed -i '/{% raw %}/d' {} \;
find -type f -exec sed -i '/{% endraw %}/d' {} \;

To get rid of date in the filenames for posts:

for file in $(ls); do 
    git mv ${file} ${file:11};
done

Note that these assume GNU sed and find, so if you're on Mac you'll need to either adapt them to BSD tools or install the GNU versions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment