Write output of bash script to file with date
bash, console, linux
Solution
Pass that string to `date`:
bash script.sh > "/var/log/$(date +%Y-%m-%d_%H:%M).log"
Problem
I'm trying to create a log file of a bash script that is run with the data. I currently have this: ``` bash script.sh > /var/log/%Y-%m-%d_%H:%M.log ``` The problem is the log file actual writes %Y-%m-%d_%H:%M and not the date. Is there way to get the date to actually write out the date by only running it in the console?