-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathrun.sh
More file actions
23 lines (18 loc) · 672 Bytes
/
Copy pathrun.sh
File metadata and controls
23 lines (18 loc) · 672 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#!/bin/bash
json_file="../../Documents/test.json"
jq_command="../jq-macos-arm64"
# Read sources and sourcesContent arrays from the JSON file
sources=($(cat $json_file | $jq_command -r '.sources[]'))
sourcesContent=($(cat $json_file | $jq_command -r '.sourcesContent[]'))
# Iterate over the indices of the array
for ((i=0; i<${#sources[@]}; i++)); do
source_file=${sources[$i]}
content=${sourcesContent[$i]}
# Check if the directory exists, create if not
if [[ ! -d $(dirname "$source_file") ]]; then
mkdir -p "$(dirname "$source_file")"
fi
# Create or update the file
touch "$source_file"
echo "$content" > "$source_file"
done