The problem is solved. However I will make a slight comment for the sake of correctness.
Quote:
Originally Posted by Tinkster
By not wrapping it in single quotes? Just kidding - that's only
half the problem. The other half is that you can't use the {}
twice ...
|
The real problem is not using it twice. You can easily check that using it twice is not a problem if you do this:
Code:
for i in $HOME -mexdepth 1 -exec echo '{}' '{}' \;
It should work as expected, printing the name of every file in the home folder two times in a row.
The problem with his expression is that the redirection operator takes precedence (and anyway, even if it didn't, find doesn't have a meaning for it anyway. So, the find command ends where the redirection starts, and the second '{}' is not in the land of find, but in the land of bash, outside find. For bash, '{}' has no special meaning, and is a textual string (and so, it's printed as that, without any kind of expansion attached to it.
So, piping the names into a loop is probably the best way:
Code:
find whatever | while read file
do
file "$file" > "${file}.log"
done
Note proper usage of quotation as well. Otherwise you'll have problems with file names containing spaces or any other special character.