Ubuntu – Copy large number of files of specific date to another directory

cpfindgrep

I've around 11K log files of specific date let say 26Feb inside one directory(there are other date data also). To copy only 26th Feb log files to destination from linux command line, I use below commands.

[root@achal logs]# ls -lrt | grep "Feb 26" | wc -l
11142

and

[root@achal logs]# find . -type f -newermt 'Feb 26' -exec cp {} 26Feb_UE_HISTORY/ \;

But it copies other date files also, not only 26th Feb files.

Any help is appreciated.

Best Answer

Your selection finds all files newer than Feb 26. So you have to exclude the files modified after Feb 26:

find . -type f -newermt 'Feb 26' ! -newermt 'Feb 27' -exec cp {} 26Feb_UE_HISTORY/ \;