In a directory there are these files and more:
- file1.txt
- file1.html
- file1.pdf
- ...
Every file1 should be replaced with newfile:
- newfile.txt
- newfile.html
- newfile.pdf
- ...
I've tried:
for f in $(ls file1*); do mv $f newfile*; done
this does replace all files with file1 to one file newfile*.
for f in $(ls file1*); do mv $f ${f/$f/"newfile"}; done
this also replaces all files with file1 to one file newfile. Or
find . -name "file1.*" -exec sh -c 'mv I DONT KNOW' _ {} \;
I don't understand how to set a part of the file name as a variable and replace this.
What is the simplest way to do this with mv?