find . -name "*.jpg" -exec echo \{\} \;
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.
${1%.conf}
is a shell parameter expansion that removes suffix .conf from the filename2.conf
adds a new suffix to the filenameIf 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