×
Create a new article
Write your page title here:
We currently have 3,189 articles on s23. Type your article name above or create one of the articles listed here!



    s23
    3,189Articles

    Find: Difference between revisions

    Content added Content deleted
    No edit summary
    imported>DrOwl
    (added some more examples)
     
    Line 8:
     
     
    === If you want to suppress error messages such as ===
     
    find / -name file
    Line 19:
    /dir/file
     
     
    <pre>
    EXAMPLE : find /var/log/ -name "20*-*-*_*.log*" -mtime +80 -exec rm {} \;
    deletes all files older than 80 days
     
    </pre>
     
    === Find files files accessed more then +n, less then -n days ===
     
    find . -mtime -100
    find . -mtime +100
     
    === Find and delete all files not access for more then 24 hours ===
     
    find . -atime +1 -exec rm '{}' \;
     
     
    === Grep through all files recursively ===
    find / -type f -exec grep -li 192.168.1.76 {} \;

    Latest revision as of 09:20, 5 August 2008

    <man>find</man>

    see also: mansearch, man2html



    Tips[edit]

    If you want to suppress error messages such as[edit]

    find / -name file 
    find: cannot read dir /lost+found: Permission denied
    /dir/file
    

    as these messages are written to errout and not stdout, a nice trick is to pipe errout to null

    find / -name file 2> /dev/null
    /dir/file
    


    EXAMPLE : find /var/log/ -name "20*-*-*_*.log*" -mtime +80 -exec rm {} \;
              deletes all files older than 80 days
    


    Find files files accessed more then +n, less then -n days[edit]

    find . -mtime -100
    find . -mtime +100
    

    Find and delete all files not access for more then 24 hours[edit]

    find . -atime +1 -exec rm '{}' \;
    


    Grep through all files recursively[edit]

    find / -type f -exec grep -li 192.168.1.76 {} \;
    
    Cookies help us deliver our services. By using our services, you agree to our use of cookies.

    Recent changes

  • BruderSpektrum • 18 hours ago
  • BruderSpektrum • 22 hours ago
  • BruderSpektrum • 22 hours ago
  • BruderSpektrum • 22 hours ago
  • Cookies help us deliver our services. By using our services, you agree to our use of cookies.