Here another bash command that needs some explanation. Can someone explain what are does the option means for the $find command mean? I know that the command finds file with 0 bytes and throw them away.
$fin开发者_运维问答d . – type f –size 0 | xargs rm ls -ld
what does the . mean? What does the | mean?
what does - type f - size 0
what is xargs ?
what does - ld mean?
rm = remove ls = list
Find takes one parameter: the directory to use as the root for the search. All other paramters are passed in as options.
find . -type f -size 0
find : The name of the program.
. : The directory to use as the root for the search.
-type f : Find only regular files. (Excludes directories, sym links, etc.)
-size 0 : Finds only empty files.
The output from the find command will be a list of empty files. This output is then fed into xargs. xargs is a program that takes a list of strings as input and then performs a given command on all of them.
The command xargs rm ls -ld
you have typed out appears erroneous. I will use xargs rm
as an example instead.
xargs rm
xargs : The name of the program.
rm : The command to run on each file.
Thus the full command find . -type f -size 0 | xargs rm
finds all empty files and deletes them.
.
is the current directory
|
pipes the output of one command (find) into the input of another (xargs)
I would suggest that you use man find
, man xargs
and man ls
to determine what the options are for find
and what exactly xargs
and ls
are doing.
精彩评论