Perform some action (e.g., echo):

find . -name "*.jpg" -exec echo \{\} \;

Change every filename in some way, based on wildcard pattern

If you want to rename every .conf to 2.conf, use find with the -exec option:

find . -name "*.conf" -type f -exec sh -c 'mv "$1" "${1%.conf}2.conf"' sh {} \;

Each filename {} is passed as parameter $1 to a new shell process started with the -exec option where the mv command is executed.

If you want to test your command before executing it, add an echo to it like:

find . -name "*.conf" -type f -exec sh -c 'echo mv "$1" "${1%.conf}2.conf"' sh {} \;
← Back to Articles