From 7021f36c94bc65a6164b559f97d9e8438bdccfd9 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Fri, 25 Nov 2016 17:25:48 +1300 Subject: Simplify cf(1df) and cfr(1df) It turns out `-exec foo {} +` is in fact POSIX behaviour (since SUSv3 as far as I can tell). --- man/man1/cf.1df | 6 ------ man/man1/cfr.1df | 15 --------------- 2 files changed, 21 deletions(-) (limited to 'man') diff --git a/man/man1/cf.1df b/man/man1/cf.1df index 9ced3c20..8434265b 100644 --- a/man/man1/cf.1df +++ b/man/man1/cf.1df @@ -10,17 +10,11 @@ .br .B cf dir1 dir2 -.br -.B cf --o dir1 dir2 .SH DESCRIPTION .B cf counts all the entries in the given directories using glob expansion and prints the count. It defaults to the current directory. .P -Giving the -o option omits printing the directory name (i.e., prints only the -count); this is intended for use in scripts such as cfr(1df). -.P It uses globs to do the counting, so it will give you unexpected results if you're counting a directory that has more than ARG_MAX entries in it. You'll have to resort to find(1) loops in that case. diff --git a/man/man1/cfr.1df b/man/man1/cfr.1df index 37dac2ad..8c3fc563 100644 --- a/man/man1/cfr.1df +++ b/man/man1/cfr.1df @@ -16,21 +16,6 @@ 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 filenames 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 . -mindepth 1 -print | wc -l -.P -However, it's subtly wrong; it will double-count anything with a path that -contains a newline! You could use -print0 and count null characters instead, -but then you've broken POSIX already. -.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 . -mindepth 1 -printf %.sx | wc -c .SH SEE ALSO cf(1df), tot(1df) .SH AUTHOR -- cgit v1.2.3