Created
January 19, 2023 20:50
-
-
Save brunos3d/9f93524b4a88d04c3ea8149293c60b21 to your computer and use it in GitHub Desktop.
A shell script that make a backup for your env files keeping the same directory structure
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 characters
#!/bin/bash | |
input_path=$1 | |
output_path=$2 | |
# Find all .env files in the input path | |
for file in $(find "$input_path" -name "*.env"); do | |
# Get the file path relative to the input path | |
relative_path="${file#$input_path/}" | |
# Create the same directory structure in the output path | |
mkdir -p "$output_path/$(dirname "$relative_path")" | |
# Copy the file to the output path | |
cp "$file" "$output_path/$relative_path" | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
just run
chmod +x ./copy-envs.sh
then./copy-envs.sh /path/to/envs /output/path/to/copies