I have files with random numbers in /home/user/files folder (every 4 days I have new ones).for example:john20john25john40tom12tom32simon2simon8simon53I want to take only last modified files (the newest) and copy them to different location (/home/user/fixed) without that numbers in file name.I know how to filter and copy that using find command but I don't know how copy all of them without that numbers.find $files_are_here -maxdepth 1 -mtime -2 -type f -exec cp {} $new_path \;This will copy all of the files modified in the last 2 days to the new path but with original name. In my case:john40tom32simon53but I would like to have only john, tom and simon inside that folder. So after I run my script again they will be replaced by the newest one.
find file, copy but with different name
bash;shell script;files;rename;file copy
The following is hopefully self explainatoryfind -maxdepth 1 -mtime -2 -type f  -exec bash -c 'name=${1##*/}; cp  $name /some/other/dir/${name%%[0-9]*}' _ {} \;