Argument list too long error for rm, cp, mv commands

前端 未结 27 3018
长情又很酷
长情又很酷 2020-11-22 04:50

I have several hundred PDFs under a directory in UNIX. The names of the PDFs are really long (approx. 60 chars).

When I try to delete all PDFs together using the fol

27条回答
  •  生来不讨喜
    2020-11-22 05:25

    Try this also If you wanna delete above 30/90 days (+) or else below 30/90(-) days files/folders then you can use the below ex commands

    Ex: For 90days excludes above after 90days files/folders deletes, it means 91,92....100 days

    find  -type f -mtime +90 -exec rm -rf {} \;
    

    Ex: For only latest 30days files that you wanna delete then use the below command (-)

    find  -type f -mtime -30 -exec rm -rf {} \;
    

    If you wanna giz the files for more than 2 days files

    find  -type f -mtime +2 -exec gzip {} \;
    

    If you wanna see the files/folders only from past one month . Ex:

    find  -type f -mtime -30 -exec ls -lrt {} \;
    

    Above 30days more only then list the files/folders Ex:

    find  -type f -mtime +30 -exec ls -lrt {} \;
    
    find /opt/app/logs -type f -mtime +30 -exec ls -lrt {} \;
    

提交回复
热议问题