map
map copied to clipboard
rarely needed
The canonical way of doing this without map in bash is not:
for f in $(ls *.c)
do
foo $f
bar $f
done
but
for f in *.c
do
foo "$f"
bar "$f"
done
because it handles whitespace in file names gracefully.
(Mantra: Don't parse the output of ls
).
And most GNU-coreutils programs handle multiple input files themselves like
file X*
wc -m *.log
head *.conf
# ... many more