From 659934efc003b3d8c99301ea9513d8d605770a03 Mon Sep 17 00:00:00 2001 From: KEINOS Date: Tue, 22 Dec 2020 12:41:45 +0900 Subject: [PATCH] Add sample to exclude file/directory. --- Recursiveness.md | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/Recursiveness.md b/Recursiveness.md index dccf746..f8740fe 100644 --- a/Recursiveness.md +++ b/Recursiveness.md @@ -31,7 +31,7 @@ find /path/to/scripts -type f \( -name '*.sh' -o -name '*.bash' -o -name '*.ksh' To check files whose shebang indicate that they are sh/bash/ksh scripts: -``` +```bash # POSIX find /path/to/scripts -type f -exec grep -Eq '^#!(.*/|.*env +)(sh|bash|ksh)' {} \; \ | xargs shellcheck @@ -41,4 +41,12 @@ find /path/to/scripts -type f -exec grep -Eq '^#!(.*/|.*env +)(sh|bash|ksh)' {} ``` docker run --volume /path/to/scripts:/mnt koalaman/shellcheck-alpine sh -c "find /mnt -name '*.sh' | xargs shellcheck" +``` + +## To exclude file/directory + +To exclude files or directories from the search(`find`) results use `! -path`. To exclude `vendor` directory for example: + +```sh +find /path/to/scripts -type f \( -name '*.sh' \) ! -path '*/vendor/*' | xargs shellcheck -x -s sh ``` \ No newline at end of file