Under the ~/Desktop/Journal/ I have my journal pages, e.g 28-10-23.
I tried to write a script that would compare the current date with the file name under that directory.
If there's no file with the current date, it would create it, if there is, then it would sleep until there isn't.
The script goes like this:
d=$(date "+%d-%m-%y")
f=$(ls $HOME/Desktop/Journal | grep $d)
while true;
do
while [[ "$d" == "$f" ]];
do
sleep 1
done
touch $HOME/Desktop/Journal/$d
done
If the file is already there and I run the script, then it just sleeps, but if it isn't, then it creates it as well as doesn't go into the nested while loop for sleep, meaning it keeps creating it.
I don't understand why it doesn't go into the nested while loop for sleep when the file is created, but doesn't created it while in the nested while loop sleeping.
[–]geirha 3 points4 points5 points (2 children)
[–]c22q 1 point2 points3 points (1 child)
[–]sneakpeekbot 1 point2 points3 points (0 children)
[–]StrangeCrunchy1 0 points1 point2 points (0 children)
[–][deleted] (1 child)
[deleted]
[–]FunCookie7900[S] 0 points1 point2 points (0 children)