Skip to content

Instantly share code, notes, and snippets.

@pen-pal
Created December 4, 2023 01:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pen-pal/2baf1780f338b0292395e2b24313210e to your computer and use it in GitHub Desktop.
Save pen-pal/2baf1780f338b0292395e2b24313210e to your computer and use it in GitHub Desktop.
create file based on parameter store name `/dev/hello/env` as `dev-hello-env` in local
/dev/hello/a
/dev/hello/b
/dev/hello/c
/dev/hello/d
/dev/hello/e
/dev/hello/f
/dev/hello/g
#!/bin/bash
# Input file path
input_file="path/to/your/input/file.txt"
# Directory where the new files will be created
output_dir="path/to/your/output/directory"
# Create output directory if it doesn't exist
mkdir -p "$output_dir"
# Read the input file line by line
while IFS= read -r line; do
# Replace '/' with '-' except the first '/'
new_file_name=$(echo "$line" | awk '{gsub(/\//,"-"); print}')
new_file_name="${new_file_name#-}"
# Create the new file with the modified name
touch "$output_dir/$new_file_name"
done < "$input_file"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment