aboutsummaryrefslogtreecommitdiff
path: root/man/man1/cfr.1df
blob: 8672d64f7642bb1cd25a55f36f032d49f8ab255d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
.TH CFR 1df "September 2016" "Manual page for cfr"
.SH NAME
.B cfr
\- print a count of entries in a directory tree
.SH SYNOPSIS
.B cfr
.br
.B cfr
/path/to/dir
.br
.B cfr
dir1 dir2
.SH DESCRIPTION
.B cf
counts all the entries in the directory trees rooted at the given arguments,
and prints the total. It defaults to the current directory. It should correctly
handle corner cases like files with newlines in them. It will count but will
not follow symbolic links.
.SH NOTES
You might think this would be better; it's certainly faster:
.P
    $ find . | wc -l
.P
However, it's subtly wrong; it will double-count anything with a path that
contains a newline!
.P
cfr(1df) and cf(1df) are POSIX-fearing as far as I can tell (please correct
me), but there are faster but less compatible ways to do this, while still
remaining accurate. Here's a method using GNU find(1) adapted from an extremely
clever suggestion from geirha on Freenode; it's much, much faster:
.P
    $ find . -printf %.sx | wc -c
.SH SEE ALSO
cf(1df), tot(1df)
.SH AUTHOR
Tom Ryder <tom@sanctum.geek.nz>