Post #3986149
2026-07-21 12:50 UTC
Let’s see, and please do not execute this “as is” since I am pulling this out of my butt. Assuming directory name is “dir1”, the file to be renamed is “crunk”, and the new name is “chunk”, then… (I assumed bash)
find dir1 -type f -name 'crunk' -exec bash -c 'mv "$0" "${0/crunk/chunk}"' {} \;
Replies (3)
-
@SoulKaribou@lemmy.ml 2026-07-21 12:55
Yes! Bash variable expansion to the rescue!
-
@sinextitan@lemmy.world 2026-07-21 13:26
for me and those that follow. could you please explain what does what?
-
@thingsiplay@lemmy.ml 2026-07-21 14:38
The the use of a bash interpreter? find -exec can run mv directly.