How can I force a re-evaluation of this each time?cat > $(date '+%H-%M-%S').logSo that when I first output something it gets written to one file, and after a few seconds I make another ouput and it will be saved in a new file.cat just symbolizes a always running program
Save lines to different files based on the date
bash;shell script;date
I replaced cat with a for loop that emits one line per second:for ch in {a..e} ; do echo $ch ; sleep 1 ; done | \while IFS= read -r line ; do printf '%s\n' $line >> $(date +%H-%M-%S) ; doneI used >> instead of > if more than one line comes in one second. You might need to add the month + day to not mix output from different days.