Updated SC2144 (markdown)

Stavros Ntentos
2020-06-12 12:59:05 +03:00
parent cbe492cbb8
commit d62c667ab4

@@ -30,6 +30,21 @@ done
Instead, use a for loop to expand the glob and check each result individually.
If you are looking for the existence of a directory, do:
```sh
for f in /path/to/your/files*; do
## Check if the glob gets expanded to existing files.
## If not, f here will be exactly the pattern above
## and the exists test will evaluate to false.
[ -e "$f" ] && echo "files do exist" || echo "files do not exist"
## This is all we needed to know, so we can break after the first iteration
break
done
```
### Exceptions
None.
@@ -37,3 +52,4 @@ None.
### Related resources:
* [BashFaq: How can I check whether a directory is empty or not? How do I check for any *.mpg files, or count how many there are?](https://mywiki.wooledge.org/BashFAQ/004)
* [sh - Check if a file exists with wildcard in shell script - Stack Overflow](https://stackoverflow.com/a/6364244/2309247)