views:

575

answers:

2

I did the commands (source):

$ exec 3>/tmp/thirdfile
$ exec 4>/tmp/fourthfile
$ echo drib >&3
$ echo drab >&4
$ echo another drib >&3
$ echo another drab >&4
$ exec 3>&-
$ exec 4>&-

How can I see the file handles, something like with "lsof -l"?

+3  A: 

On Linux, you can do something like ls -l /proc/$$/fd, which will show you what file descriptors are open in your shell.

Of course, substitute $$ with other numbers to inspect other processes (at least, the ones you own).

Chris Jester-Young
+4  A: 

I don't understand, why not just use lsof:

lsof -p $$

$$ being a shell variable that holds the shell's process ID

You can also limit to just file descriptors like:

lsof -a -d0-65535 -p $$
derobert