Linux system to delete the specified time period file method

  
                

The method of deleting files in batches under Linux system is very simple, but it is more difficult to delete files in a specified time. It needs to be implemented by Linux scripts. The following small series will introduce you to the method of deleting files in Linux within a specified time.

find find deleted files

For example finds all ending in .txt files from the current directory and display them on the screen, the command line:

find. -name ‘*.txt’ -print

Find the files with the two suffixes and change to the following usage:

find . ( -name *.xml -o -name *.sh )

Another example is to find a file with the symbolic connection from the root directory and delete it. Command behavior:

find /- Type l -exec rm {} ;

Find only files, not including directories (this line, can't add --print, adds an error):

find . -type f

Another example is to find all the files of the user tom from the current directory and display them on the screen. The command behavior is:

find . -user ‘tom’ -print

Another example is to display the .c file name in the current directory that is larger than 20 bytes. The command behavior is:

find . -name “*.c” -size +20c -print

Displays the name of the file that was accessed just 10 days ago in the current directory. Command behavior:

find . -atime 10 -print

Displays the file name that was accessed less than 10 days ago in the current directory. Command behavior:

find . -atime -10 -print

Find files or directories with permissions of 640 in the /home directory. Command behavior:

find /home -perm 640

Search under the root directory Files larger than 100KB, and display, command behavior:

find /-size +100K -print
Previous12Next Total 2 Pages

Copyright © Windows knowledge All Rights Reserved