2005-1-14 Linux Find and Xargs Commands

xiaoxiao2021-03-06  38

In the morning, I learned a part of the time to learn Find and Xargs .... I learned again. Continue Ha ~~~

Find -name

-Perm

-prune

-user

-group

-mtime -n n

Find ~ .name "* .txt" -print

~ Representing your $ home

Find. -name "* .txt" -print

Find / etc / -name "host *" -print

Find. -perm 755 -print

Find. -perm -007 -print absolute mode (such as umask)

Ignore a directory

Find / apps -name "/ apps / bin" -prune -o -print

Find / -MTIME -5 -PRINT

Find / var / adm -mtime 3 -print

Find. -size 1000000c -print

Find / home / apache -size 100c -print file just 100 bytes

Find. -size 10 -print 10 file (a piece equal to 512)

Find / -Name "con.file" -Depth -print matches this file

Find / var / logs -type f -mtime 5 -EXEC RM {} /;

Find the / var / logs directory to change the normal file before 5 days, and delete.

When using the -EXEC option to use the FIND command, the Find command passes all the matching files to Exec.

Execution, unfortunately there is a system that is limited to the command length that can be passed to exec, so after the Find command runs a few minutes, it will

An overflow error occurs, the error message is usually "parameter too long" or "parameter column overflow". This is the use of the xargs command, especially

Used together with the Find command. The Find command passes the matching file to the xargs command, and the xargs command reads only some files instead of all, you can use a batch of processes, use the -exec options to initiate a process for each matching file, And using Xargs commands only one process. When using the Xargs command, it is determined by all parameters or batch acquisition, which will be determined according to the options for the command and the corresponding adjustable parameters in the system kernel.

Find / -type f -print | xargs grep "device"

Find / Apps / Audit -Perm -7 -Print | Xargs Chmod O-W

转载请注明原文地址:https://www.9cbs.com/read-69030.html

New Post(0)