local variable inside for body isn't exported to outside, remember to use set -x
option.
for <var-name> in $list_variable
echo $<var-name>
end
Note: you could replace $list_variable
with foo bar baz
Note 2: when declaring var-name, it's the name, not the variable substitution.
Single directory
for file in /path/to/directory
for file in /path/to/directory/
All directories inside a directory
for dir in /path/to/directory/*/
(remember the trailing backspace, or it will print both files and dirs)
All files inside a directory
for file in /path/to/directory/*
All files inside multiple directory
for file in /path/to/directory/*/*