I'm trying to follow this answer but I can't make it work.
I simplified it down as much as I could to try work out what's going on (just running this at the terminal for now):
rsync --progress -iav /my/dir1 /my/dir2 | awk '{ print($0) }'
But it only prints messages likersync: failed to set times on [file]
.
What am I doing wrong?
Edit: On further investigation it seems like awk is doing some sort of buffering. This:
for i in 10 20 30; do echo $i; sleep 1; done | awk '{print $0}'
Demonstrates a problem where no output is seen until 3 seconds have passed.
So I guess the question is how do I get awk to flush its buffer? I tried:
for i in 10 20 30; do echo $i; sleep 1; done | awk '{print($0); fflush()}'
Which had the same problem.
awk '{print $0}'
? That will just print the input line. Are you trying to remove the buffering? What is your actual objective? Also, please always mention which operating system and what version of awk you are using. Is this on Linux? Unix? OSX? – terdon Jun 05 '15 at 16:39fflush()
orfflush("")
don't seem to do anything. I'm glad there's a work-around with-W interactive
– Adrian Pronk Aug 14 '22 at 22:49