Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
replaces patterns like "<? cmd ?>" by executing cmd
#
# awk one-liner to replace patterns like "<? cmd ?>" by executing cmd
# handy for use in config files "templates"
#
cat <<EOF | awk '{ if (match($0, /<\?(.*)?>/)) { cmd = substr($0, RSTART+2, RLENGTH-2-2); system(cmd) } else print }'
my directory has these files:
<? ls / ?>
EOF
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.