I see this command advised, whenever a person asks online about renaming all uppercase files to lowercase:
find "$(pwd)" -depth -exec rename 's/(.*)\/([^\/]*)/$1\/\L$2/' {} \;
I understand the find "$(pwd)" -depth -exec rename
part.
Can someone breakdown and explain the regex command of rename - namely: 's/(.*)\/([^\/]*)/$1\/\L$2/'
Why
\/([^\/]*)
and not only(.*)
?I know what
$1
is in the context of bash, but what does$1
,\L$2
mean inrename
?I would also appreciate how is this different from a simple
find "$(pwd)" -depth -exec rename 'y/A-Z/a-z/' {} \;
Finally, what book or resources would you recommend to learn this kind of stuff? I read the
rename
man-page; however, I did not find explanations there about this type of usage.