[You don't even need the (ls) for file iteration:
for i in *
echo $i
end
]You don't even need the for for that (specific example):
echo *
at least in sh and bash.
for i in *
echo $i
end
]You don't even need the for for that (specific example):
echo *
at least in sh and bash.
for i
do
# your commands using $i here
done
which will iterate over all the command line arguments to the script containing that for loop.
It is a shortcut for: for i in $*
# note: not for i in *
# the rest is the same above
This is mentioned in either the shell man page or in the Kernighan & Pike book The Unix Programming Environment. for file in *; do
echo "$file"
done