Cat a directory

Karlsson Mikael HKI/SOSV mikael.karlsson at hel.fi
Thu Sep 18 01:42:37 PDT 2003


I've noticed along time that it's possible to cat a directory. I just
don't see the point of it being possible to do so since it only returns
jibrish.

I know that in Linux for example cat returns an error message like this:
cat: mail/: Is a directory. I also noticed that in both FreeBSD and
Linux less returns the same error message. But vi and vim on the other
hand returns fully readable and understandable text in both FreeBSD and
Linux.

What I just wanted to ask was if it's absolutely necessary for cat to be
able to work on directories. Or if it would be possible to simply add a
check to cat that tests if the "file" being opened is a directory and
then exits with an error message if that is the case.

The biggest problem for me as a "Unix" help-person at a company is to
always explain to newbies and less experienced users not to cat
directories as it usually scrambles or locks the whole terminal and as
they then turn to me to undo their mistakes. These small simple things
give our users bad thoughts about FreeBSD and often drives them to use
other OSs!




More information about the freebsd-questions mailing list