-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathprocess_dates.sh
More file actions
31 lines (23 loc) · 866 Bytes
/
process_dates.sh
File metadata and controls
31 lines (23 loc) · 866 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#!/bin/bash
# Check if start and end date are provided
if [ "$#" -ne 2 ]; then
echo "Usage: $0 <start_date> <end_date>"
exit 1
fi
start_date="$1"
end_date="$2"
# Convert start and end dates to seconds since epoch
start_sec=$(date -d "$start_date" +%s)
end_sec=$(date -d "$end_date" +%s)
# Loop through the date range
current_sec=$start_sec
while [ $current_sec -le $end_sec ]; do
# Convert current date to the desired format
current_date=$(date -d "@$current_sec" +%Y-%m-%d)
# Use sed to update the date in the get_cloud_free.json file
sed -i "s/\"date\": \"[^\"]*\"/\"date\": \"$current_date\"/" get_cloud_free.json
# Run the command with the updated get_cloud_free.json
colonies function submit --spec get_cloud_free.json
# Move to the next day
current_sec=$((current_sec + 86400)) # Add 86400 seconds (1 day)
done