I have a rather simple script (print content from a tty after adding timestamp to every row). It outputs nicely on the command line, but redirecting the output with >
does not work. Why not?
Here is the script:
#!/bin/bash
awk '{ print strftime("%Y-%m-%d %H:%M:%S |"), $0; }' "$1"
Running it as is, like timecat /dev/ttyACM0
works fine, I see the content in my terminal.
But if I run timecat /dev/ttyACM0 > ~/tmp.log
, nothing comes out. Same with tee
. The file is there, but it is empty.
Is there something weird with awk
in the script, how can I modify this to make the redirection work?