You can remove the line FILES=`ls *.sql` and replace ${FILES} by *.sql, shell expansion will take care of finding the files.
–
LekensteynMar 2 '11 at 14:48

This isn't the most concise way, but I do appreciate the readability and explanation. If I'm going to do this from the command line, I'd rather type what chrish shows, but if I were saving it as a script, I'd definitely use your way for readability.
–
Nathan LongMar 2 '11 at 14:51

1

@Matt Jenkins: the readability does not increase by adding another ls command. Keep it simple. By the way, I think the { are bashish, it's better to replace them by do and done: for ...; do ...; done
–
LekensteynMar 2 '11 at 14:53

Well forgive me for writing portable code. ls.. is just one source of files that the script could handle; it would be trivial to change it to use, say, a predefined list of files, or command line arguements, by just editing this variable. No need to change the structure of the for if you want to put the script to another use. Isn't that the point of this site? To give answers that are of interest to the genral populace? If that means making your scripts a little more wordy and a little more understandable then I don't see a problem with ls.. as it implicitly shows what is being worked on.
–
MajenkoMar 2 '11 at 15:01