On 10/25/2016 4:16 AM, JaceK wrote:
> In books I have read so far it is usually said that directory is actually a file with
> special structure. The content of such file is name of files in directory and their
> inodes (maybe something more but the books weren't that specific).
That's correct. A directory is a two-column table, more or less.
See /usr/include/bits/dirent.h for the exact definition of
struct dirent on Linux.
>
> One can cat regular file to see its content. Is there a command to cat a directory?
I don't think Linux allows that, but I believe some Unixes do (if
you are root anyway). I know I used to be able to do that, it made
a good demo. My memory (not very good anymore) was Solaris and AIX
allowed that.
However, you can come very close with just:
\ls -i | cat
The backslash turns off aliases, and the "|cat" turns off some
terminal processing as well, such as converting non-printable
characters into question-marks. Fun demo to see the difference:
touch AB^V[BS]C
(That's control-V followed by a backspace.) When you run the
above command, you will see "AC". Without the cat, you will
see "AB?C".
--
Wayne