Merge c9bdc254b2
into 8c19d0b482
This commit is contained in:
commit
d53020bdad
|
@ -836,6 +836,7 @@ Don’t use `ls`.
|
|||
|
||||
```shell
|
||||
# Greedy example.
|
||||
shopt -s nullglob
|
||||
for file in *; do
|
||||
printf '%s\n' "$file"
|
||||
done
|
||||
|
@ -849,6 +850,7 @@ done
|
|||
for dir in ~/Downloads/*/; do
|
||||
printf '%s\n' "$dir"
|
||||
done
|
||||
shopt -u nullglob
|
||||
|
||||
# Brace Expansion.
|
||||
for file in /path/to/parentdir/{file1,file2,subdir/file3}; do
|
||||
|
@ -1006,14 +1008,17 @@ count() {
|
|||
|
||||
```shell
|
||||
# Count all files in dir.
|
||||
$ shopt -s nullglob
|
||||
$ count ~/Downloads/*
|
||||
232
|
||||
|
||||
# Count all dirs in dir.
|
||||
$ shopt -s nullglob
|
||||
$ count ~/Downloads/*/
|
||||
45
|
||||
|
||||
# Count all jpg files in dir.
|
||||
$ shopt -s nullglob
|
||||
$ count ~/Pictures/*.jpg
|
||||
64
|
||||
```
|
||||
|
|
Loading…
Reference in New Issue