envz_merge - Linux
Overview
envz_merge is a tool for merging environment variables from multiple sources into a single, unified environment. It allows users to combine variables from files, command output, and the existing environment, simplifying the management and sharing of configurations across applications and scripts.
Syntax
envz_merge [options] <source1> [<source2> [<source3> ...]]
Options/Flags
-f
,--file
: Read environment variables from a file.-c
,--command
: Read environment variables from the output of a command.-e
,--existing
: Use the existing environment as a source.-o
,--output
: Write the merged environment variables to a file.-j
,--json-output
: Write the merged environment variables in JSON format.-s
,--separator
: Specify the separator to use when merging variables (default: newline).-h
,--help
: Print help and usage information.
Examples
Merge variables from multiple files:
envz_merge -f file1.env -f file2.env > merged.env
Merge variables from a file and command output:
envz_merge -f file1.env \
-c "echo VAR1=value1" \
> merged.env
Merge variables from the existing environment:
envz_merge -e -f file1.env
Write merged variables to a JSON file:
envz_merge -f file1.env -j merged.json
Common Issues
- Duplicate variable names: If multiple sources define the same variable name, the value from the last source will be used.
- Invalid or empty sources: Ensure that all sources provided are valid and contain environment variables.
Integration
envz_merge can be combined with other tools for more complex tasks, such as:
- Variable expansion: Using the environment variables merged by envz_merge in subsequent commands or scripts.
- Configuration management: Using envz_merge to manage configuration files that rely on multiple environment variables.
Related Commands
- envsubst: Substitute environment variables in a text file.
- source: Load environment variables from a file into the current environment.