Last active
April 4, 2020 16:44
-
-
Save vanduc1102/d08d91f02113dea97ed8f854b4600d3d to your computer and use it in GitHub Desktop.
convert file twit to php bash
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
for file in *.twig; | |
do | |
output="${file//-/_}" # convert all - to _ | |
output="${output/.twig/_php_output_array}" # convert .twig to _php_output_array | |
init_output="<?php\n\n\$${output} = array();\n/** \n" | |
return_output="\n*/\nreturn \$${output};" | |
file_content=$(cat $file) | |
echo "${init_output}\n$file_content\n${return_output}" > "$file"; | |
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
for file in *.twig; do mv "$file" "${file/.twig/.php}"; done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment