Skip to content

Instantly share code, notes, and snippets.

@ronamosa
Last active December 9, 2017 09:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ronamosa/519d255362352f48d925a771486c2026 to your computer and use it in GitHub Desktop.
Save ronamosa/519d255362352f48d925a771486c2026 to your computer and use it in GitHub Desktop.
handy command line snippets
# description:
# inserts a new field after an existing field in a yaml file
# scenario:
# needed to add "comments: true" to all my github page blog posts (*.md)
# explain:
# -i = edit file in place
# -e = regex
# 's = substitute
# find this "/published\:\ true/"
# replace with this "/published\:\ true/"
# plus "\ncomments\:\ true/" (note the new line '\n'
# do this all files that match ".md"
sed -i -e 's/published\:\ true/published\:\ true\ncomments\:\ true/' *.md
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment