aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Ryder <tom@sanctum.geek.nz>2016-11-25 20:10:54 +1300
committerTom Ryder <tom@sanctum.geek.nz>2016-11-25 20:10:54 +1300
commite8b95f88c45f9c915d30f09bf337c47f14860e22 (patch)
treea68c8737c2efdc5f2dcbab4d47eb692331cb81d7
parentSimplify cf(1df) with a find(1) command (diff)
downloaddotfiles-e8b95f88c45f9c915d30f09bf337c47f14860e22.tar.gz
dotfiles-e8b95f88c45f9c915d30f09bf337c47f14860e22.zip
Add finc(1df)
-rw-r--r--README.markdown2
-rwxr-xr-xbin/finc3
-rw-r--r--man/man1/finc.1df22
3 files changed, 27 insertions, 0 deletions
diff --git a/README.markdown b/README.markdown
index 1dd1643c..b2fab759 100644
--- a/README.markdown
+++ b/README.markdown
@@ -427,6 +427,8 @@ Installed by the `install-bin` target:
`~/.local/bin`, for personal scripting snippets.
* `fgscr(1df)` finds Git repositories in a directory root and scrubs them
with `gscr(1df)`.
+* `finc(1df)` counts the number of results returned from a set of given
+ `find(1)` conditions.
* `fnl(1df)` runs a command and saves its output and error into temporary
files, printing their paths and line counts
* `gms(1df)` runs a set of `getmailrc` files; does much the same thing as the
diff --git a/bin/finc b/bin/finc
new file mode 100755
index 00000000..e8e6b974
--- /dev/null
+++ b/bin/finc
@@ -0,0 +1,3 @@
+#!/bin/sh
+# Count the number of entries from a find(1) condition
+find "$@" -exec printf .%sx {} + | wc -c
diff --git a/man/man1/finc.1df b/man/man1/finc.1df
new file mode 100644
index 00000000..19f895ac
--- /dev/null
+++ b/man/man1/finc.1df
@@ -0,0 +1,22 @@
+.TH FINC 1df "November 2016" "Manual page for finc"
+.SH NAME
+.B finc
+\- accurately count results from a find(1) search
+.SH SYNOPSIS
+.B finc
+.br
+.B finc
+/path/to/dir
+.br
+.B finc
+/dira /dirb -type f -name 'a*'
+.SH DESCRIPTION
+.B finc
+runs find(1) with the given conditions and accurately counts the number of
+results, handling special cases like newlines in filenames.
+.P
+Don't add your own actions to it (-print, -exec etc) or you'll mess it up.
+.SH SEE ALSO
+cf(1df), cfr(1df)
+.SH AUTHOR
+Tom Ryder <tom@sanctum.geek.nz>