You can use cp –remove-destination option to remove each existing destination file before attempting to copy it (contrast with –force which forcefully overwrites the destination file)
1 2 3 4 5 6 7 8 |
mkdir mydir ## create some files and directories touch myfile mydir/myfile chmod 444 mydir/myfile cp myfile mydir ## error, Permission denied cp --remove-destination myfile mydir ## Successfull rm -r my* |