I have a Bash one-liner that redirects the output of a command to a new, fresh file each time the command is run. Logging the output of each time the command is run is important (I'm using
ls here as an example, but the actual command is
ansible-playbook and is unlikely to be anything else):
$ ls -hl | tee logs/$(date "+%Y-%m-%d_%H:%M:%S").log
This is cumbersome to type and hard to remember, but it does what I require (as long as I do not run the command more than once per second). Running the command multiple times will produce logs in the
/logs folder such as:
$ ls logs/
What I'd like to know is: is there an existing Bash command I'm unaware of that will achieve the same, or something quite similar? The format of the log's name is important (date or Unix epoch preferred).