What is the use of "-u" option in cat command? [closed]
Per the POSIX standard for cat
:
SYNOPSIS
cat [-u] [file...]
...
OPTIONS
...
The following option shall be supported:
-uWrite bytes from the input file to the standard output without delay as each is read.
That could be implemented by disabling buffering on the output.
The idea behind cat -u
is indeed that the output should be unbuffered, so that even if cat
is in a pipeline, the data will be written promptly as it is read.
It can matter when you use cat -u "$@" | …
and the input is, in fact, coming from a keyboard.
The chances are that GNU cat
effectively works without buffering (using direct read()
and write()
calls), so the -u
option is irrelevant — it always works in 'unbuffered mode'.