Well actually it isn't... Wierd things happens when whitespace gets involved in for loops
A file listing like this
-rw-r--r-- 1 sajko users 88 2009-07-18 15:58 tmp 1.php
-rw-r--r-- 1 sajko users 1014 2009-04-23 23:05 tmp.sh
-rw-r--r-- 1 sajko users 531 2009-07-15 08:41 tmp.txt
-rw-r--r-- 1 sajko users 266 2009-04-15 15:22 tst.sh
would make a for loop go abit crazy.
This can be remedied by not using long listing. In which case it would look like this
This would present another issue thou. Since there's a space in the file name this would make itterations look like this
where neither 1.php or tmp exists (or even worse, they do exist).
The solution to this problem is the IFS environment variable.
Will change the itteration separator to a new line instead of any whitespace character (newline, space or tab) making it usable when a space character is in the file name, or when you parse columned files.
There are several other things that gets abit wacky but you'll figure them out while you get along with your bash programming.
Recommended thou is that you learn to handle the bash commands for stream editing, programs like sed, cut, awk, replace, tr and so on
ps. Using the absolute path (as described in my previous post) instead of running a command to populate your for loop condition does not present the above problem. The shell automagically escapes characters that could pose a problem as part of the expanding of the *. Also you'll get the full path and then file name which ls won't give you. You can use "basename" to remove the absolute path ds.