Linux下如何统计文件数目
2011-06-19 18:32
246 查看
若只是查看当前目录下的文件数目(除开.和..文件),使用下面的命令:
$ find ./ -type f | wc -l
若查看当前目录下面的所有文件,含.和..使用如下命令即可:
$wc -l
ps:find command and wc command
1、FIND命令
NAME
find - search for files in a directory hierarchy
SYNOPSIS
find [path...] [expression]
DESCRIPTION
This manual page documents the GNU version of
find. find searches the
directory tree rooted at each given file name by
evaluating the given
expression from
left to right, according to the
rules of precedence
(see section OPERATORS), until the outcome is known (the left hand
side
is false for and operations, true for or), at which point find
moves on
to the next file name.
The first argument that begins with `-', `(', `)', `,', or `!' is
taken
to be the
beginning of the expression;
any arguments before it are
paths to search, and any arguments after it are the rest of the
expres-
sion. If
no paths are given, the current
directory is used. If no
expression is given, the expression `-print' is used.
find exits with status 0 if
all files are
processed successfully,
greater than 0 if errors occur.
OPTIONS
All options always return
true. They always take effect, rather than
being processed only when their place in
the expression
is reached.
Therefore, for
clarity, it is best to place them at the
beginning of
the expression.
-daystart
Measure times (for -amin,
-atime, -cmin,
-ctime, -mmin, and
-mtime) from
the beginning of today rather than from 24
hours
ago.
-depth Process each directory's contents before the directory
itself.
-follow
Dereference symbolic links. Implies -noleaf.
-help, --help
Print a summary of the command-line usage of find and exit.
-maxdepth levels
Descend at most levels (a non-negative integer) levels of
direc-
tories below
the command line arguments.
`-maxdepth 0' means
only apply the tests and actions to the command
line arguments.
-mindepth levels
Do not apply any tests or actions at levels less
than levels (a
non-negative integer). `-mindepth 1'
means process
all files
except the command line arguments.
-mount Don't descend
directories on other
filesystems. An alternate
name for -xdev, for compatibility with some
other versions of
find.
-noleaf
Do not
optimize by assuming that
directories contain 2 fewer
subdirectories than their hard
link count.
This option is
needed when
searching filesystems that do not follow the
Unix
directory-link convention, such as CD-ROM or
MS-DOS filesystems
or AFS volume
mount points. Each directory on
a normal Unix
filesystem has at least 2 hard
links: its
name and its
`.'
entry.
Additionally, its
subdirectories (if any) each have a
`..' entry linked to that
directory. When find is
examining a
directory, after it has statted 2 fewer
subdirectories than the
directory's link count, it knows that the rest of the entries
in
the directory are non-directories (`leaf' files in the
directory
tree). If only the files' names need to be
examined, there is
no need to
stat them;
this gives a significant increase in
search speed.
-version, --version
Print the find version number and exit.
-xdev Don't descend directories on other
filesystems.
2、WC命令
wc - print the number of bytes, words, and lines in files
SYNOPSIS
wc [OPTION]... [FILE]...
DESCRIPTION
Print byte, word, and newline counts for each FILE, and a total
line if
more than one FILE is specified. With no FILE, or
when FILE is -, read
standard input.
-c, --bytes
print the byte counts
-m, --chars
print the character counts
-l, --lines
print the newline counts
-L, --max-line-length
print the length of the longest line
-w, --words
print the word counts
--help display this help and exit
--version
output version information and exit
$ find ./ -type f | wc -l
若查看当前目录下面的所有文件,含.和..使用如下命令即可:
$wc -l
ps:find command and wc command
1、FIND命令
NAME
find - search for files in a directory hierarchy
SYNOPSIS
find [path...] [expression]
DESCRIPTION
This manual page documents the GNU version of
find. find searches the
directory tree rooted at each given file name by
evaluating the given
expression from
left to right, according to the
rules of precedence
(see section OPERATORS), until the outcome is known (the left hand
side
is false for and operations, true for or), at which point find
moves on
to the next file name.
The first argument that begins with `-', `(', `)', `,', or `!' is
taken
to be the
beginning of the expression;
any arguments before it are
paths to search, and any arguments after it are the rest of the
expres-
sion. If
no paths are given, the current
directory is used. If no
expression is given, the expression `-print' is used.
find exits with status 0 if
all files are
processed successfully,
greater than 0 if errors occur.
OPTIONS
All options always return
true. They always take effect, rather than
being processed only when their place in
the expression
is reached.
Therefore, for
clarity, it is best to place them at the
beginning of
the expression.
-daystart
Measure times (for -amin,
-atime, -cmin,
-ctime, -mmin, and
-mtime) from
the beginning of today rather than from 24
hours
ago.
-depth Process each directory's contents before the directory
itself.
-follow
Dereference symbolic links. Implies -noleaf.
-help, --help
Print a summary of the command-line usage of find and exit.
-maxdepth levels
Descend at most levels (a non-negative integer) levels of
direc-
tories below
the command line arguments.
`-maxdepth 0' means
only apply the tests and actions to the command
line arguments.
-mindepth levels
Do not apply any tests or actions at levels less
than levels (a
non-negative integer). `-mindepth 1'
means process
all files
except the command line arguments.
-mount Don't descend
directories on other
filesystems. An alternate
name for -xdev, for compatibility with some
other versions of
find.
-noleaf
Do not
optimize by assuming that
directories contain 2 fewer
subdirectories than their hard
link count.
This option is
needed when
searching filesystems that do not follow the
Unix
directory-link convention, such as CD-ROM or
MS-DOS filesystems
or AFS volume
mount points. Each directory on
a normal Unix
filesystem has at least 2 hard
links: its
name and its
`.'
entry.
Additionally, its
subdirectories (if any) each have a
`..' entry linked to that
directory. When find is
examining a
directory, after it has statted 2 fewer
subdirectories than the
directory's link count, it knows that the rest of the entries
in
the directory are non-directories (`leaf' files in the
directory
tree). If only the files' names need to be
examined, there is
no need to
stat them;
this gives a significant increase in
search speed.
-version, --version
Print the find version number and exit.
-xdev Don't descend directories on other
filesystems.
2、WC命令
wc - print the number of bytes, words, and lines in files
SYNOPSIS
wc [OPTION]... [FILE]...
DESCRIPTION
Print byte, word, and newline counts for each FILE, and a total
line if
more than one FILE is specified. With no FILE, or
when FILE is -, read
standard input.
-c, --bytes
print the byte counts
-m, --chars
print the character counts
-l, --lines
print the newline counts
-L, --max-line-length
print the length of the longest line
-w, --words
print the word counts
--help display this help and exit
--version
output version information and exit
相关文章推荐
- Linux下如何统计文件数目
- linux下统计当前文件夹中文件的数目以及如何查看文件夹的大小
- linux统计文件夹中文件数目
- 如何统计Linux环境变量中各个目录下的文件数
- 如何统计 Linux 中文件和文件夹/目录的数量 | Linux 中国
- Linux 统计当前文件夹、文件的数目
- linux下如何统计一个目录下的文件个数以及代码总行数的命令
- Linux下统计某个目录文件数目
- Linux终端上统计指定类型文件的数目的方法
- Linux统计文件数目
- linux下如何统计一个目录下的文件个数以及代码总行数的命令
- linux中文件数目统计
- Linux统计文件数目
- linux下如何统计一个目录下的文件个数以及代码总行数的命令
- Linux统计文件夹下的文件数目
- linux下如何统计一个目录下的文件个数以及代码总行数的命令
- linux下如何统计一个目录下的文件个数以及代码总行数的命令
- 如何轻松在win和linux之间互传文件
- linux:如何在Linux下统计高速网络中的流量
- Linux如何通过命令查看日志文件的某几行(中间几行或最后几行)