Please use [code][/code]
tags around your code, to preserve formatting and to improve readability. (You have over a hundred posts, so you should be aware of this by now
You can turn off smilies when posting too.
Now for some scripting tips:
1) Don't use a for
loop when reading from files or commands. Any input with a space in it would break it. Use a while+read
2) Useless use of cat
. Inside a command substitution $(<filename)
does just the same job (well, except that any final newline will be removed). And if you use the while loop I mentioned in #1, you can feed it directly (example below).
3) $(..) is highly recommended over `..`
don't use backticks, they're hard to read, easy to mistake, and completely unnecessary.
4) Always quote variable expansions, as word-splitting is done after expansion. (This is also why the command substitution in #1 is a problem).
With that said, here's a better example of colucix's code:
while read x ; do