find in glob, ignore glob added

This commit is contained in:
Rick van Lieshout 2021-09-27 16:20:47 +02:00
parent 037faf024e
commit baf79376c8
2 changed files with 13 additions and 0 deletions

View File

@ -14,6 +14,7 @@ It also consolidates all relevant examples in 1 place
```sh ```sh
. .
├── bash ├── bash
│ ├── find-all-without.sh # find all files with glob (*) whilst ignoring another glob (*)
│ ├── parsing-command-line-params.sh │ ├── parsing-command-line-params.sh
│ ├── remove-parentheses.sh # script to remove parentheses from all files in a directory (recursively) │ ├── remove-parentheses.sh # script to remove parentheses from all files in a directory (recursively)
│ └── whiptail.sh # tiny demo of how whiptail works │ └── whiptail.sh # tiny demo of how whiptail works

12
bash/find-all-without.sh Normal file
View File

@ -0,0 +1,12 @@
## this script shows you how to find files matching a certain glob (*.csproj) but ignoring another glob (*.test.csproj)
CSPROJFILE=$(find . -iname '*.csproj' -a ! -iname '*test.csproj')
# ^ ^ ^ ^ ^ ^ ^
# assign var | | | | | |
# find | | | | |
# case insensitive search | | | |
# ending with *.csproj | | |
# logical and not | |
# case insensitive name search |
# ending with test.csproj
echo "$CSPROJFILE"