Last active
August 25, 2023 04:29
-
-
Save mattkenefick/6ff3d3b4b17c1e9f43d0908cf830bbd2 to your computer and use it in GitHub Desktop.
Revisions
-
mattkenefick revised this gist
Jan 9, 2019 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -44,6 +44,6 @@ Results: The copy and paste example will create the two example files, the merge script, make it executable, execute it, then display the results. Note: This will not execute properly on Windows Cmder because of the multi-line heredoc. It should work just fine in a standard terminal, Git bash, etc.
-
mattkenefick revised this gist
Jan 9, 2019 . 1 changed file with 3 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,3 +1,6 @@ # Purpose If you're making a project where you need a base level of configs and various combinations of overrides... this `merge.sh` script will let you combine multiple `.env` or `.ini` files (key/value) and remove duplicates based on the key. # Usage Example -
mattkenefick revised this gist
Jan 9, 2019 . 1 changed file with 5 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -2,15 +2,17 @@ # Usage Example Create both files in a structure like: ``` specific.env base.env merge.sh ``` Run `sh merge.sh specific.env base.env` Results: `cat merged.env` # Copy and Paste Example -
mattkenefick created this gist
Jan 9, 2019 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,44 @@ # Usage Example Create both files in a structure like: specific.env base.env merge.sh Run sh merge.sh specific.env base.env Results: cat merged.env # Copy and Paste Example echo 'name=Barbara Miller city=Brooklyn' > specific.env; echo 'name=John Doe city=Manhattan state=NY zip=10001' > base.env; cat > merge.sh <<\EOF #!/bin/bash cat $1 > tmp0 cat $2 >> tmp0 awk -F "=" '!a[$1]++' tmp0 > tmp1 && mv tmp1 merged.env && rm tmp0 EOF chmod 0755 merge.sh; sh merge.sh specific.env base.env; cat merged.env; The copy and paste example will create the two example files, the merge script, make it executable, execute it, then display the results. Note: This will not execute properly on Windows Cmder because of the multi-line EOF. It should work just fine in a standard terminal, Git bash, etc.
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,4 @@ name=John Doe city=Manhattan state=NY zip=10001 This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,7 @@ #!/bin/bash cat $1 > tmp0 cat $2 >> tmp0 awk -F "=" '!a[$1]++' tmp0 > tmp1 && mv tmp1 merged.env && rm tmp0 This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,2 @@ name=Barbara Miller city=Brooklyn