Use of the Find command and the tar command

Source: Internet
Author: User

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

  1. Find [PATH] [option] [action]
  2. # time-related parameters:
  3. -mtime N: = n is a number, meaning a file that has been changed in "One Day" before the nth day;
  4. -mtime +n: Lists the file names that were changed before n days (excluding the N-day itself);
  5. -mtime-n: Lists filenames that have been changed within n days (including n days themselves);
  6. -newer file: List file names that are newer than file
  7. For example
  8. Find/root-mtime 0 # Find files that have changed within the current directory today
  9. # parameters related to user or user group name:
  10. -user Name: List files with file owner name
  11. -group Name: List files that belong to the user group named name
  12. -uid N: List file owner as User ID n
  13. -gid N: Lists files that belong to the user group whose user group ID is n
  14. For example
  15. Find/home/ljianhui-user Ljianhui # Find the owner-Ljianhui file in the directory/home/ljianhui
  16. # Parameters related to file permissions and names:
  17. -name FileName: Find the file named filename
  18. -size [+-]size: Find a file larger than size (+) or small (-)
  19. -tpye Type: Find file of type of file, the value of type is mainly: General file (f), device file (b, C),
  20. Directory (d), connection file (L), socket (s), FIFO pipeline file (p);
  21. -perm mode: Find file permissions just equal to the mode file, mode is represented by a number, such as 0755;
  22. -perm-mode: Find file permissions must all include the mode permission of the file, mode is represented by a number
  23. -perm +mode: Find file Permissions file that contains the permissions of either mode, mode is represented by a number
  24. For example
  25. Find/-name passwd # Finding files with file name passwd
  26. Find. -perm 0755 # 0755 file to find file permissions in the current directory
  27. 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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.