Skip to content

Commit b644c6f

Browse files
committed
refactor: ♻️ Add a few bits around globbing
1 parent f8c39eb commit b644c6f

File tree

1 file changed

+24
-3
lines changed

1 file changed

+24
-3
lines changed

16_globbing/README.md

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,27 @@ Demonstrates techniques for globbing and operating on sets of files
44

55
TODO:
66

7-
1. Use globbing from shell
8-
1. Using globbing in scripts
97
1. shopts and controlling behaviour
10-
1. path expansion
8+
2. path expansion
9+
10+
## Looping
11+
12+
```sh
13+
# enter shell
14+
bash
15+
16+
# enable globbing
17+
set +f
18+
19+
# loop
20+
counter=1
21+
for file in *; do
22+
echo "$file -> ${counter}"
23+
counter=$((counter + 1))
24+
done
25+
```
26+
27+
## Oneliners
1128

1229
```bash
1330
# For each directory name create an empty file in the out directory with the filename the same as the directory
@@ -25,9 +42,13 @@ find .. -name "[0-9][0-9]_*" -exec echo {} \;
2542
grep -R "/usr/bin/env" --include="*.sh" ../*
2643
```
2744

45+
## Zsh
46+
2847
```zsh
2948
# zsh
3049
setopt extendedglob
3150
ls ^d*.txt
3251
unsetopt extendedglob
3352
```
53+
54+
## Resources

0 commit comments

Comments
 (0)