ahoffman: find total files

Go on then, I'll bite:

What SHOULD I have suggested to bsher to find the "total files in a directory"? ls -la shows all files, (plus . & .. & the total blocks line), so ls -la |grep "^-" |wc -l counts the ordinary files.

Or am I still missing something?
LVL 21
tfewsterAsked:
Who is Participating?
 
ahoffmannConnect With a Mentor Commented:
well, just assume that your UNIX/Linux runs Samba, and what the stupid clients may create as file- or directory names ;-))
(in german we may call it: DAUs,  which I won't translate to prevent some flames:-)
0
 
ahoffmannCommented:
depending on you ls, you may have fun with this:

   touch 'a\^Jb'

(where ^J is ESC followed by return)

BTW, FreeBSD's ls automatically handles such things as one line, but not SunOS, Solaris, HP-UX, IRIX, and most Linux

(not really a question, so I'm not afraid that the question will be deleted, after we got some more comments ;-)
0
 
tfewsterAuthor Commented:
Touche - I made a couple of assumptions in my answer to bsher 1) that it was a simple query & 2) I didn't consider odd filenames, [although I've seen problems in the past with filenames with control characters in them].

"An assumption is the first step towards a foul-up"

I stand corrected & the points are yours, unless someone else has a more amusing example of how directories  can get messed up.

0
All Courses

From novice to tech pro — start learning today.