Skip to content

Instantly share code, notes, and snippets.

@wesleyit
Created January 27, 2015 15:10
Show Gist options
  • Save wesleyit/a509356c4c3fa5176887 to your computer and use it in GitHub Desktop.
Save wesleyit/a509356c4c3fa5176887 to your computer and use it in GitHub Desktop.
This script will expand variables inside a file and generate a new file with the same name, but without the ".sh" extension.
#!/bin/bash
# ##########################################################
# parse_shell_infile.sh
# This script will expand variables inside a file
# and generate a new file with the same name, but
# without the ".sh" extension.
# Wesley Rodrigues da Silva <wesley.it at gmail.com>
# LICENCE CREATIVE COMMONS BY - 2014
# http://creativecommons.org/licenses/by/2.0/legalcode
# ##########################################################
IN="$1"
OUT="${IN/.sh/}"
echo "Criando o arquivo $OUT a partir do template $IN..."
CODE=$(eval "echo \"$(cat $IN)\"")
echo "$CODE" > $OUT
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment