i want to move the files older than 10 day's to backup path when i have used based on the below commands it was working fine for me when i ran individual each command

find /home/abc/def/xyz-sw-n2/log/ -type f -name *.txt -mtime +10 -print

find /home/abc/def/xyz-sw-n2/accesslog/ -type f -name *.csv -mtime +10 -print

find /home/abc/def/eguard/ -type f -name *.csv -mtime +10 -print

find /home/abc/def/xxxv6/logs/ -type f -name *.csv -mtime +10 -print

find /home/abc/def/yyy/request/log/ -type f -name *.log -mtime +10 -print

find /home/abc/def/zzz-core/logs -type f -name *.log -mtime +10 -print

when i ran this below command there is a problem that if any configuration file or important file which is with *.csv or *.log or *.txt will get moved


find . -type f \( -name *.csv -o -name *.txt -o -name *.log \) -mtime +10 -print

in your system there is no particular format naming convention for the log's *.csv or *.log or *.txt

how to make it automate


Put the name specifiers between double quotes:

find . -type f \( -name "*.csv" -o -name "*.txt" -o -name "*.log" \) -mtime +10 -print

works on my system.

| improve this answer | |
  • 2
    If the -name argument in find command contains wildcards, it should always be written in quotes. Even the man page for the find command says that. – raj Sep 22 at 13:28
  • Hi Jos, Thanks for the update but my concern is if i ran the below command it will move the main configuration file. find . -type f ( -name ".csv" -o -name ".txt" -o -name "*.log" ) -mtime +10 -print for example: find /home/abc/def/xyz-sw-n2/log/ -type f -name *.txt -mtime +10 -print find /home/abc/def/xyz-sw-n2/alerts/config/email/1234/ -type f -name *.txt -mtime +10 -print (Main Config File) – Jagadish Kumar Sep 23 at 1:06
  • @JagadishKumar I don't understand your comment. In your question, you never mention a main config file, and none of the commands moves anything. – Jos Sep 23 at 7:21
  • @jos i want to move the log's – Jagadish Kumar Sep 24 at 7:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.