Demonstrates techniques for globbing and operating on sets of files
TODO:
- shopts and controlling behaviour
- path expansion
# enter shell
bash
# enable globbing
set +f
# loop
counter=1
for file in *; do
echo "$file -> ${counter}"
counter=$((counter + 1))
done
# For each directory name create an empty file in the out directory with the filename the same as the directory
mkdir ./out
echo ../* | xargs -n1 | sed 's/..\//.\/out\//g' | xargs -I % touch %
# For each directory echo out the name
find .. -name "[0-9][0-9]_*" -exec echo {} \;
# Find all shell scripts with shebang.
grep -R "/usr/bin/env" --include="*.sh" ../*
# zsh
setopt extendedglob
ls ^d*.txt
unsetopt extendedglob