From 31b01f1ba4000f13572b88023e640dcf750868a9 Mon Sep 17 00:00:00 2001 From: Colin Chan Date: Mon, 15 Jun 2015 20:09:18 -0700 Subject: [PATCH] Improve `find` commands It's more straightforward to use quotes around the pattern arguments rather than escaping the asterisks with backslashes. Also, find (the GNU version, at least) requires the path to come before the expression. --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 2c82c83..55622f6 100644 --- a/README.md +++ b/README.md @@ -59,7 +59,7 @@ Scope: - Use `xargs` (or `parallel`). It's very powerful. Note you can control how many items execute per line (`-L`) as well as parallelism (`-P`). If you're not sure if it'll do the right thing, use `xargs echo` first. Also, `-I{}` is handy. Examples: ``` - find . -name \*.py | xargs grep some_function + find . -name '*.py' | xargs grep some_function cat hosts | xargs -I{} ssh root@{} hostname ``` @@ -123,7 +123,7 @@ Scope: ## Processing files and data -- To locate a file by name in the current directory, `find -iname *something* .` (or similar). To find a file anywhere by name, use `locate something` (but bear in mind `updatedb` my not have indexed recently created files). +- To locate a file by name in the current directory, `find . -iname '*something*'` (or similar). To find a file anywhere by name, use `locate something` (but bear in mind `updatedb` my not have indexed recently created files). - For general searching through source or data files (more advanced than `grep -r`), use [`ag`](https://github.com/ggreer/the_silver_searcher). @@ -240,7 +240,7 @@ A few examples of piecing together commands: - Use `xargs` or `parallel` whenever you can. Note you can control how many items execute per line (`-L`) as well as parallelism (`-P`). If you're not sure if it'll do the right thing, use xargs echo first. Also, `-I{}` is handy. Examples: ``` - find . -name \*.py | xargs grep some_function + find . -name '*.py' | xargs grep some_function cat hosts | xargs -I{} ssh root@{} hostname ```