I am trying to rename a file using find
command.
I am trying to rename file-a to file-10.
To do this I first tried below command:
sps@sps-Inspiron-N5110:~$ find ~ -type f -name test-a -exec mv test-10 '{}' ';'
mv: cannot stat `test-10': No such file or directory
sps@sps-Inspiron-N5110:~$
Then I tried below:
sps@sps-Inspiron-N5110:~$ find ~ -type f -name test-a -exec mv test-a test-10 '{}' ';'
mv: target `/home/sps/test-a' is not a directory
sps@sps-Inspiron-N5110:~$
Now I cant think how to do that with find
. I am trying to do this with find
, because I will have many directories with same filename, and I want to change all the test-a
to test-10
in one command. Anyone please suggest.
Thanks.
test-a
(and intended to be renamed totest-10
)? Or is your goal to search for files whose names end in-a
(but may otherwise be anything) and rename them to end in-10
instead?