Skip to content

Instantly share code, notes, and snippets.

@mortennobel
Last active December 12, 2015 10:09
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 mortennobel/4757446 to your computer and use it in GitHub Desktop.
Save mortennobel/4757446 to your computer and use it in GitHub Desktop.
replaces blocks of text surrounded by start and end symbol with a constant line (useful for simple preprocessing scripts)
awk '/insert_code_start/,/insert_code_end/ { if ( $0 ~ /insert_code_end/) print " // insert code here"; next} 1' < test.cpp > text_sub.cpp
#
# Example
#
# void main(){
# // insert_code_start
# foo();
# // insert_code_end
# }
#
# Turns into
# void main(){
# // insert code here
# }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment