Bit of a strange request.
I’d like have a window where I can record a list of ad-hoc notes, with a timestamp for each note.
I’ve written the following which works:
$ while read line
> do
> echo $(date +%H:%M:%S) $line
> done | tee log
Hello
21:35:30 Hello
World
21:35:32 World
Is there a more elegant way of doing this?
If you care about preserving whitespace, quote your variable $line. The date format %T is equivalent to %H:%M:%S. You may want to append to the log file.
Otherwise, the only thing I can think of to make it more eleganter is to put in in a function.