Cat a directory

Warren Block wblock at wonkity.com
Mon Sep 22 16:37:22 PDT 2003


"Karlsson Mikael HKI/SOSV" <mikael.karlsson at hel.fi> wrote:

> So it's better for a newbie to get understandable jibrish from cat
> when run on directories then an error message stating that they are
> trying to run cat on a directory like ls says when they try to run ls
> on a file. But as I said earlier who cares, right? Other OSs have only
> had this for "a couple" of year so why would we!!!

This might all be based on a misunderstanding.  Using cat on a directory
is not producing useless garbage.  For example, try

cat /etc | hexdump -C		# UUOC, I know

Section 18.02 in O'Reilly's "Unix Power Tools" (if you don't have it
already, get it) describes this in more detail.

Modifying cat so it couldn't do this would not be an improvement.

I hope this helps, and thanks for giving me the motivation to look it
up.

-Warren Block * Rapid City, South Dakota USA


More information about the freebsd-questions mailing list