From ce1598198ea4878edc97df16d9061be75eca7b9b Mon Sep 17 00:00:00 2001 From: Johannes Stoelp Date: Thu, 20 Feb 2025 21:25:46 +0100 Subject: find: initial notes --- src/SUMMARY.md | 1 + src/cli/README.md | 1 + src/cli/find.md | 31 +++++++++++++++++++++++++++++++ 3 files changed, 33 insertions(+) create mode 100644 src/cli/find.md diff --git a/src/SUMMARY.md b/src/SUMMARY.md index 4a606f4..c1f7cca 100644 --- a/src/SUMMARY.md +++ b/src/SUMMARY.md @@ -19,6 +19,7 @@ - [paste](./cli/paste.md) - [xargs](./cli/xargs.md) - [grep](./cli/grep.md) + - [find](./cli/find.md) - [Tools](./tools/README.md) - [tmux](./tools/tmux.md) diff --git a/src/cli/README.md b/src/cli/README.md index 6b7a661..ffde988 100644 --- a/src/cli/README.md +++ b/src/cli/README.md @@ -11,3 +11,4 @@ - [paste](./paste.md) - [xargs](./xargs.md) - [grep](./grep.md) +- [find](./find.md) diff --git a/src/cli/find.md b/src/cli/find.md new file mode 100644 index 0000000..9597cdb --- /dev/null +++ b/src/cli/find.md @@ -0,0 +1,31 @@ +# find(1) + +``` +find [opts] + -maxdepth maximally search n dirs deep + -type match on file type + f regular file + d directory + -user list files owned by username + -name list files matching glob (only filename) + -iname list files matching glob case-insensitive + + -exec {} ; run cmd on each file + -exec {} + run cmd with all files as argument +``` +> Depending on the shell the `` must be quoted or escaped. The +> exec modifier characters `;` and `+` also may need to be escaped. + +### Example `-exec` option +```sh +> find . -maxdepth 1 -type d -exec echo x {} \; +# x . +# x ./.github +# x ./book +# x ./src +# x ./.git +# x ./docs + +> find . -maxdepth 1 -type d -exec echo x {} + +# x . ./.github ./book ./src ./.git ./docs +``` -- cgit v1.2.3