If I use:
strace echo 'a
b
c' > file
The bottom lines are:
write(1, "a\nb\nc\nd\n", 8) = 8
but in
strace echo 'a
b
c
d' > /dev/pts/0
These lines are:
write(1, "a\n", 2) = 2
write(1, "b\n", 2) = 2
write(1, "c\n", 2) = 2
write(1, "d\n", 2) = 2
In second case, why does it is writing line by line, whereas in first case it is writing together. May be because terminal is character device, but I got definition of character device as:
A character (char) device is one that can be accessed as a stream of bytes (like a file).The only relevant difference between a char device and a regular file is that you can always move back and forth in the regular file, whereas most char devices are just data channels, which you can only access sequentially.
Edit: Shell is bash.
strace
, notice. – JdeBP Feb 20 '19 at 18:48strace
changing the behaviour? I pointed out that we don't need to know which shell. That's not a shell, by the way, PRY. – JdeBP Feb 20 '19 at 18:52