Linux wc命令及统计文件夹下文件及文件夹个数
wc命令及统计文件夹下文件及文件夹个数1. 统计文件夹下文件及文件夹个数2. wc 命令:2.1 参数:2.2 例子:1. 统计文件夹下文件及文件夹个数统计当前目录下文件的个数(不包括目录)$ ls -l | grep "^-" | wc -l//普通文件以-开头统计当前目录下文件的个数(包括子目录)$ ls -lR| grep "^-" | wc -l查看某目录下文件夹(目录)的个数(包括子目录
·
Linux wc命令及统计文件夹下文件及文件夹个数
1. 统计文件夹下文件及文件夹个数
统计当前目录下文件的个数(不包括目录)
$ ls -l | grep "^-" | wc -l
//普通文件以-开头
统计当前目录下文件的个数(包括子目录)
$ ls -lR| grep "^-" | wc -l
查看某目录下文件夹(目录)的个数(包括子目录)
$ ls -lR | grep "^d" | wc -l
//普通文件夹以d开头
2. wc 命令:
wc (Word Count)命令的功能为统计指定文件中的字节数、字数、行数,并将统计结果显示输出
2.1 参数:
-c 统计字节数
-l 统计行数
-m 统计字符数。这个参数不能与 -c 参数一起使用。
-w 统计字数。一个字被定义为空白、跳格或换行字符分隔的字符串。
-L 打印最长行的长度
--help 显示帮助信息
--version 显示版本信息
2.2 例子:
[root@localhost test]# wc main.c
66 149 1433 main.c
//行数 单词 字节
[root@localhost test]#
[root@localhost memory-poll]# wc -c main.c
1433 main.c
[root@localhost memory-poll]# wc -l main.c
66 main.c
[root@localhost memory-poll]# wc -m main.c
1433 main.c
[root@localhost memory-poll]# wc -w main.c
149 main.c
[root@localhost memory-poll]# wc -version
wc: invalid option -- 'v'
Try 'wc --help' for more information.
[root@localhost memory-poll]# wc --version
wc (GNU coreutils) 8.22
Copyright (C) 2013 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Written by Paul Rubin and David MacKenzie.
[root@localhost memory-poll]# wc --help
Usage: wc [OPTION]... [FILE]...
or: wc [OPTION]... --files0-from=F
Print newline, word, and byte 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. A word is a non-zero-length sequence of characters
delimited by white space.
The options below may be used to select which counts are printed, always in
the following order: newline, word, character, byte, maximum line length.
-c, --bytes print the byte counts
-m, --chars print the character counts
-l, --lines print the newline counts
--files0-from=F read input from the files specified by
NUL-terminated names in file F;
If F is - then read names from standard input
-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
GNU coreutils online help: <http://www.gnu.org/software/coreutils/>
For complete documentation, run: info coreutils 'wc invocation'
[root@localhost memory-poll]# wc -L m
main.c memory_pool.c memory_pool.h
[root@localhost memory-poll]# wc -L main.c
74 main.c
[root@localhost memory-poll]#
更多推荐
已为社区贡献4条内容
所有评论(0)