Home Messages Index
[Date Prev][Date Next][Thread Prev][Thread Next]
Author IndexDate IndexThread Index

Re: Number of Files

Gordon Henderson wrote:

> In article <d2mc3i$2413$3@godfrey.mcc.ac.uk>,
> Roy Schestowitz  <newsgroups@schestowitz.com> wrote:
> 
>>I have just set up an alias...
>>
>>alias nfiles='du -all >~/temp; wc ~/temp; rm ~/temp;'
>>
>>I hope it won't be harmful or risky.
> 
> Probably not, but not that efficient. Firstly, a little more command-line
> learning will help here. Remember we are dealing with a fully
> multi-tasking operating system, so lets dump the temporary file and
> replace it with a pipe:
> 
>   du -all | wc -l
> 
> will save the creation of temporary file. (and subsequent deletion, with
> the slight possibility that you could overwrite an existing file!)
> 
> Next, find is probably quicker than du. Especially if it's just files
> you want to count and skip over directories:
> 
>   find . -type f | wc -l
> 
> Note the 'wc -l' - this just prints the lines. Characters and words which
> 'wc' also prints probably isn't useful here.
> 
> And now we're getting back to the old, traditional Unix paradigm which
> is the ability to connect lots of small programs together to form
> something more complex, yet still be something that can be broken down
> into individual parts. Why write a program to do this, (and thus bloat
> your distribution) when there already exists the basic tools right at
> your fingertips :) (</mini-rant>)

You convinced me and I have changed the alias. Thank you all for the help.

Roy

-- 
Roy S. Schestowitz
http://Schestowitz.com

[Date Prev][Date Next][Thread Prev][Thread Next]
Author IndexDate IndexThread Index