find . -name '*.txt' -exec sh -c 'x="{}"; mv "$x" "${x//2010/2022}"' \;
Whats under the hood?
- find command finds the files that ending with *.txt using -name parameter
- -exec parameter executes move (
mv
) command for each found file - second move argument
${x//2010/2022}
replaces string2010
with2022
in file names using shell parameter expansion