ls -la /dev/tty
shows the output:
crw-rw-rw- 1 root tty 5, 0 Dec 14 22:21 /dev/tty
What does c at the beginning mean? When I do something like pwd > /dev/tty
it prints to the stdout. What does the file /dev/tty contain?
This question is related to
unix
The 'c' means it's a character special file.
/dev/tty
is a synonym for the controlling terminal (if any) of the current process. As jtl999 says, it's a character special file; that's what the c
in the ls -l
output means.
man 4 tty
or man -s 4 tty
should give you more information, or you can read the man page online here.
Incidentally, pwd > /dev/tty
doesn't necessarily print to the shell's stdout (though it is the pwd
command's standard output). If the shell's standard output has been redirected to something other than the terminal, /dev/tty
still refers to the terminal.
You can also read from /dev/tty
, which will normally read from the keyboard.
Source: Stackoverflow.com