Tar command
TAR-ZCVF small.tar.gz Small (directory name) (compressed)
TAR-ZXVF small.tar.gz Small (directory name) (unzip)
Find command
Find./-mtime 5-print (search within 5 days for file data)
10M or more file data searched
- Find [PATH] [option] [action]
- # time-related parameters:
- -mtime N: = n is a number, meaning a file that has been changed in "One Day" before the nth day;
- -mtime +n: Lists the file names that were changed before n days (excluding the N-day itself);
- -mtime-n: Lists filenames that have been changed within n days (including n days themselves);
- -newer file: List file names that are newer than file
- For example
- Find/root-mtime 0 # Find files that have changed within the current directory today
- # parameters related to user or user group name:
- -user Name: List files with file owner name
- -group Name: List files that belong to the user group named name
- -uid N: List file owner as User ID n
- -gid N: Lists files that belong to the user group whose user group ID is n
- For example
- Find/home/ljianhui-user Ljianhui # Find the owner-Ljianhui file in the directory/home/ljianhui
- # Parameters related to file permissions and names:
- -name FileName: Find the file named filename
- -size [+-]size: Find a file larger than size (+) or small (-)
- -tpye Type: Find file of type of file, the value of type is mainly: General file (f), device file (b, C),
- Directory (d), connection file (L), socket (s), FIFO pipeline file (p);
- -perm mode: Find file permissions just equal to the mode file, mode is represented by a number, such as 0755;
- -perm-mode: Find file permissions must all include the mode permission of the file, mode is represented by a number
- -perm +mode: Find file Permissions file that contains the permissions of either mode, mode is represented by a number
- For example
- Find/-name passwd # Finding files with file name passwd
- Find. -perm 0755 # 0755 file to find file permissions in the current directory
- Find. -size +12k # Find files larger than 12KB in the current directory, note that C means byte
The difference between-exec and Xargs in Find
When you execute at the command line:
$find. -name ' core '-type f-exec rm {}/;
, the Find-exec command performs a separate RM operation on each matching file (execute a separate RM for each one), as you manually type the following command:
Xargs, as the name implies, is the command to process parameters. Its task is to convert the input rows into the argument list of the next command. So the above find-exec command can be rewritten as:
Find. -name ' core '-type F-print | Xargs RM
Package by Search Results
Use of the Find command and the tar command