Merging two ini/env keyval files and remove duplicate keys using awk (gist.github.com) 1 points by mattkenefick 7y ago ↗ HN
[–] mattkenefick 7y ago ↗ I ran into this issue today and couldn't find a great solution online.Needed to combine multiple key/value files, like .ini or .env, and have some values override others while removing duplicates.This script + example demonstrates how to use awk to remove duplicate lines based on their key.
[–] flatfilefan 7y ago ↗ What is your expected merged.env content? Lines from which file take precedence? Listing it will help understanding your use case. [–] mattkenefick 7y ago ↗ specific overrides base. top down.Could be whatever way you want it to be really, but that's the case here.
[–] mattkenefick 7y ago ↗ specific overrides base. top down.Could be whatever way you want it to be really, but that's the case here.
3 comments
[ 1.9 ms ] story [ 22.3 ms ] threadNeeded to combine multiple key/value files, like .ini or .env, and have some values override others while removing duplicates.
This script + example demonstrates how to use awk to remove duplicate lines based on their key.
Could be whatever way you want it to be really, but that's the case here.