I need redirect output to file and add datetime.
I try this:
make all | awk '{ print strftime("%Y-%m-%d %H:%M:%S"), $0; }' > file
I expect:
2011-12-13 15:00:50 compilation....
2011-12-13 15:00:52 still compilation
2011-12-13 15:00:55 compilation
...
How can I do this? If i remove “> file” on the screen i seen correct output. But I will redirect this to file.
Can anybody help me?
Try
teecommand like this:tee will display output on STDOUT and store the output in file as well.