I’m trying to copy $CurrentFile from $CurrentDir to $CurrentBackup. The problem that I’m having is that this file copies every $CurrentFile from parent directory.
So for example,
let say input is this
CurrentDir=/home/usr/logs
CurrentFile='SystemOut_*'
CurrentDay=6
CurrentBackup=/backup
But, this command will copy every $CurrentFile from /home/usr/Serverinf to $CurrentBackup…
find . $CurrentDir . -type f -name $CurrentFile -mtime +$CurrentDay -exec cp {} $CurrentBackup \;
I’m not sure what I did wrong…Can anyone tell me what I did wrong?
If I can’t use this command, could you tell me alternative command for this?
Thanks for your help!
As far as I can tell the problem is the extra dots:
You’re telling find to search in the current directory and
$CurrentDir. Get rid of the dots and also use double quotes to prevent the shell from expanding names beforefindever sees them.