Find the answer to your Linux question:
Results 1 to 2 of 2
I need help with my find command. I want to search files that are older than 500 days and remove them. Before I did this I decided it would be ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Linux Newbie mactruck's Avatar
    Join Date
    Apr 2012
    Location
    City of Salt
    Posts
    187

    help with find command


    I need help with my find command. I want to search files that are older than 500 days and remove them. Before I did this I decided it would be nice to print a list of the files to a tmp file so I can verify my script is working before I delete something that I was not supposed to. I ran the script below and it gives me a list of all the old files. The only problem is it is listing hidden folders. I do not want to remove any hidden folders or files. I thought I did that with the -type f \( ! -name ".*" \) command but it is still listing hidden folders.

    Code:
    find . -type f \( ! -name ".*" \) -mtime +500 -exec ls -l {} \; > ~/MIKE/old/500days$dttm.txt
    I have tried this:

    Code:
    find . -type f \( ! -name ".*" \) -type d \( ! -name ".*" \) -mtime +500 -exec ls -l {} \; >> ~/notp/MIKE/old/500days$dttm.txt
    but this will not look in any folders or sub-folders
    Last edited by mactruck; 02-20-2013 at 07:36 PM.

  2. #2
    Linux Engineer
    Join Date
    Apr 2012
    Location
    Virginia, USA
    Posts
    900
    cd /path/to/dir
    find * -type f ...

    Or, find /path/to/dir/* -type f ..

    NOT find /path/to/dir*

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •