Home tmade.de

Home Wiki

find

find . -printf "%T@ %Tx %TX %p\n" | sort -n -r | head | cut -d ' ' -f 2-   #Find newest file in actual directory
find . -printf "%T@ %Tx %TX %p\n" | sort -n | head | cut -d ' ' -f 2-      #Find oldest file in actual directory
find / -name filename                                                      #Find file "filename" in /
find / -uid user_ID -exec rm {}\;                                          #Delete files from any user (systemwide):
find /home -mtime +7 -name core -exec rm -f {} \;                          #Removes the file "core" if older than 7 days without promting
find . -mtime +30 -exec rm {} \;                                           #Removes all files in working directory if older than 30 days without promting
find /tmp -mtime +5 -exec rm {} \;                                         #Removes files in "/tmp" older 5 days
find /tmp/* -mtime +5 -exec rm -rf {} \;                                   #Delete all files or folders older than 5 days
find /path/to/files/ -type f -name "*.tar" -mtime +20 -exec rm {} \;       #Delete all files in path older than 20 days with extension *.tar
find /sourcedirectory -mtime +365 -exec ls -al "{}" /dest/directory/ \;    #List results for testing
find /sourcedirectory -mtime +30 -exec mv "{}" /destination/directory/ \;  #Moves files older 30 days from sourcedirectory to destination
find . -name "*.bak" -type f -print0 | xargs -0 /bin/rm -f                 #Delete all files called "*.bak" recursivly from workingdirectory
find /somedir -type f -exec chmod 644 {} \;                                #Find files in "/somedir" and chmod to 644
find . -type d -exec chmod 775 {} \;                                       #Find folder in "." and change to 775
find . -type f -print0 | xargs -0 chmod 666                                #Find files in "." and chmod to 666
find . -name "*.sh" -type f -print0 | xargs -0 chmod 700                   #Find all files named "*.sh" in "." and chmod to 700
shell/find.txt · Last modified: 2020/06/20 05:10 by tmade
 
Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Noncommercial-Share Alike 4.0 International
Recent changes RSS feed Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki