I have some shell script which generates some outputs. The output is written into a file. In my cronjob I have it: ./myscript.sh --options > output Because the cronjob runs every week, I would like to keep a list of outputs instead of overwritting them every time the script runs. So ideally I would like to have the output file name as output_*date*. Date is current script running date. In Unix, date command can give you current date info, but how could I integrate that into the output file name?
Have tried Heath and wfaulk's methods, it does work well. However, when I put the same command in cronjob, I started to get the error: /bin/sh: -c: line 0: unexpected EOF while looking for matching `)' /bin/sh: -c: line 1: syntax error: unexpected end of file
I know it's caused by output to a file named output_$(date +%Y%m%d) since that's the only change I made. Is there a different way to do it in cronjob?