1

I code this

$ ls -l 1> stdout.txt

and I get the output as desired,

1> stdout.txt

redirects the output from standard output to the file stdout.txt.

I don't see any such file existing on disk. What kind of file system supports such files, is it ramfs?

Does this have any similarity to the procfs and sysfs?

5
  • 1
    It doesn't matter what kind of filesystem is in use. If you use 1> stdout.txt (or, more commonly, just > stdout.txt), you should get a file called stdout.txt in the current directory. If the file can't be opened in the current directory (permission problem or some other error), you should get an error message informing you of this.
    – Celada
    Commented May 5, 2013 at 17:54
  • my Question was,in what type of file system do we have stdout, stdin. they do have file descriptors, so they are files, right? i was expecting something on the lines of procfs and sysfs or some other kind of psuedo fs
    – ArunMKumar
    Commented May 5, 2013 at 18:43
  • 1
    stdin, stdout, and stderr are file descriptors, not files. They may refer to files (or pipes, or sockets, etc...). In this case you made the stdout file descriptor (which is 1) refer to your file stdout.txt in the current directory. It doesn't matter what type of filesystem stdout.txt lives on.
    – Celada
    Commented May 5, 2013 at 19:04
  • What “such file” are you refering to? The only file involved in that command is stdout.txt, which the command creates. Commented May 7, 2013 at 1:46
  • such file is the one with the file descriptor 1, i obviously know that the txt file is not inquestion, maybe i didn't put the question in the right way, but its fine. got the answer. its procfs, thanks to @sukminder
    – ArunMKumar
    Commented May 7, 2013 at 4:14

1 Answer 1

2

If you are on Linux, and I read your question correctly, yes look in /proc.

For a specific process look in /proc/[pid]/fd, e.g. ls -l /proc/123/fd/

There is also a special way to reach current process fd's by: /proc/self/fd.

Note that e.g. ls -l /proc/self/fd would be for the ls process and not for your current shell, which you can see by:

cat /proc/self/cmdline | tr '\000' '\n'

or

cat /proc/self/status

For the last look especially at PPid which should be PID of your shell.

Name:   cat
State:  R (running)
Tgid:   12696
Pid:    12696
PPid:   312

As an experiment you could try to open two terminal windows:

  1. In window 1 enter echo $$ to get PID of that shell.
  2. In window 2 say cat /proc/[pid]/fd/1
  3. In window 1 start typing and observe what happens in window 2.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .