Skip to content

Instantly share code, notes, and snippets.

@aa6my
Forked from kamermans/fix_quotes.sh
Created May 12, 2020 02:53
Show Gist options
  • Save aa6my/714c044e47b43651c22cf7b6d3cdeaad to your computer and use it in GitHub Desktop.
Save aa6my/714c044e47b43651c22cf7b6d3cdeaad to your computer and use it in GitHub Desktop.
Replace fancy-quotes / curly-quotes / smart-quotes with standard ASCII single- and double-quotes in bash
#!/bin/bash
# Replaces annoying "fancy" quotes created by programs like Microsoft Word and everything in MacOS
# with normal ASCII single-quotes (') or double-quotes (")
# This script does NOT replace the GRAVE ACCENT (`) since it is commonly used in Markdown and as a bash command
# See: https://www.cl.cam.ac.uk/~mgk25/ucs/quotes.html
SINGLE=$(echo -ne '\u00B4\u2018\u2019')
DOUBLE=$(echo -ne '\u201C\u201D')
sed -i "s/[$SINGLE]/'/g; s/[$DOUBLE]/\"/g" $1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment