$ { echo "1-"
for i in {1..100} ; do
yes -- -abcdefghijklmnopqrstuvwxyz |
head -10000 &
done
} | grep -E ^.+- | head
1-
-abcdefghijk-abcdefghijklmnopqrstuvwxyz
-abcdefghijklmno-abcdefghijklmnopqrstuvwxyz
-abcdefg-abcdefghijklmnopqrstuvwxyz
-abcdefg-abcdefghijklmnopqrstuvwxyz
-abcdefg-abcdefghijklmnopqrstuvwxyz
-abcdefg-abcdefghijklmnopqrstuvwxyz
-abcdefg-abcdefghijklmnopqrstuvwxyz
-abcdefg-abcdefghijklmnopqrstuvwxyz
-abcdefg-abcdefghijklmnopqrstuvwxyz
That makes sense as the output buffers could flush at any time and do
not have to end on line endings. That's why there are minus signs in
between the characters.
To force "line buffering" apparently I can pipe the output through
perl with the "flush buffers" option turned on:
$ { echo "1-"
for i in {1..100} ; do
yes -- -abcdefghijklmnopqrstuvwxyz |
head -10000 |
perl -pe '$|=1'
done
} | grep -E ^.+- | head
1-
My ruby question is, can I replace the perl with ruby and, if so, how?
Regards,
- Robert
Arggggh. Such is my luck today: google for ten minutes, find nothing.
Send post to list, then go back to google, and find exactly what I'm
looking for: IO#sync
http://ruby-doc.org/core/classes/IO.html#M002263
$ { echo "1-"
for i in {1..100} ; do
yes -- -abcdefghijklmnopqrstuvwxyz |
head -10000 |
ruby -pe 'STDOUT.sync = true' &
done
} | grep -E ^.+- | head
1-
Does ruby have a shorthand version to specify autoflush?
Regards,
- Robert