Recently have faced with an issue during bulk copying files that contains '$' symbol in the name. What I'm trying to achieve, I have bunch of sub-sub folders containing a lot of files inside, but I'm interesting only in some of them, e.g. *.html files. I want copy all of html files into new dir.
My first command for this:
find . -name \*.html -exec sh -c "cp {} newDir/newFileName_<randomVal>.html" \;
<- this return me proper number (seems to) of copied files. But also in console I'm getting errors like 'file not found' to those that containing '$' symbol..
Next I changed a 'cp {}' sub-command to ... -c "cp '{}' ..."
in order to get filename as a string value. No errors appear now, but using this command I'm getting duplicates of the files, e.g. I know that inside folders 10 html files, but after executing a command getting 20 html files..
So, is there any another way to achieve desirable result, or what's wrong with this command?
10x