Last active
March 12, 2020 22:12
-
-
Save kbfreder/c3688b819e87f7071a6df2036aea2b9a to your computer and use it in GitHub Desktop.
loop through dates in a bash script. Also uses a while loop, and if and not/then statements
This file contains 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 | |
# loop through dates, using GNU dates | |
# GNU date reference: https://www.gnu.org/software/coreutils/manual/html_node/Examples-of-date.html | |
# define paths | |
open_path=../data/raw | |
save_path=../data/processed | |
# define dates | |
start_date=2020-02-25 | |
end_date=2020-03-04 | |
d=$start | |
# end date | |
while [ "$d" -lt 2020-03-04 ]; do | |
# define file names, which are based on date | |
DATAFILE=$open_path/new_domains_$d.pkl | |
SAVEFILE=$save_path/new_domains_predict_$d.pkl | |
# if DATAFILE exits, but not SAVEFILE | |
if [ -f "$DATAFILE" ] && [ ! -f "$SAVEFILE" ] | |
then | |
# run python script | |
python3 predict.py -f $DATAFILE -o $SAVEFILE -s -v | |
else | |
echo "cannot find $DATAFILE or $SAVEFILE already exists" | |
fi | |
# increment date | |
d=$(date -I -d "$d + 1 day") | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment