I want to transform/"translate" all files in a folder from lower to uppercase. I could use a for
loop to do that:
for i in ./* ; do mv $i $(echo $i | tr "a-z" "A-Z") ; done
for i in `find . -maxdepth 1 -mindepth 1` ; do mv $i $(echo $i | tr "a-z" "A-Z") ; done
But I'm wondering why tr
does not work within find
:
find . -maxdepth 1 -type f -exec mv {} $(echo {} | tr "a-z" "A-Z") \;
It just prints the file names once again, with changing them to upper case. Why does the find
version not work?
My goal is to use find
instead of a for
loop.
$( )
construct is executed before find is run ? – Archemar Oct 08 '19 at 07:11