When I run the command
find dir_1 -type f -name 'f*'
I found 2 files there "file_11" and "file_22". Now I want to move those files to another directory "dir_2" using -exec with the "find" command. So I use this command.
find dir_1 -type f -name 'f*' -exec mv {} ../dir2 \;
This command works.
Now, there are also some ".txt" files in the directory "dir_1". I want to move these text files to "dir2" and also rename these files. so I use this command,
find dir_1 -type f -name '*.txt' -exec mv {} ../dir2/new_{} \;
But I am getting the error,
mv: cannot move 'dir_1/file1.txt' to '../dir2/new_dir_1/file1.txt': No such file or directory
mv: cannot move 'dir_1/file2.txt' to '../dir2/new_dir_1/file2.txt': No such file or directory
Can anyone help me.