linux命令行下载文件看有多少文件个数

Posts - 135,
Articles - 0,
Comments - 65
17:32 by 依水间, ... 阅读,
语法:wc [选项] 文件&
说明:该命令统计给定文件中的字节数、字数、行数。如果没有给出文件名,则从标准输入读取。wc同时也给出所有指定文件的总统计数。字是由空格字符区分开的最大字符串。
该命令各选项含义如下:
  - c 统计字节数。
  - l 统计行数。
  - w 统计字数。
这些选项可以组合使用。
输出列的顺序和数目不受选项的顺序和数目的影响。
总是按下述顺序显示并且每项最多一列。
行数、字数、字节数、文件名
如果命令行中没有文件名,则输出中不出现文件名。
$ wc - lcw file1 file24 33 file17 52 file211 11 85 total
举例分析:
1.统计demo目录下,js文件数量:
find demo/ -name "*.js" |wc -l
2.统计demo目录下所有js文件代码行数:
find demo/ -name "*.js" |xargs cat|wc -l&或&wc -l `find ./ -name "*.js"`|tail -n1
3.统计demo目录下所有js文件代码行数,过滤了空行:
find /demo -name "*.js" |xargs cat|grep -v ^$|wc -lLinux查看所有子文件夹及文件的数量_Linux教程_Linux公社-Linux系统门户网站
你好,游客
Linux查看所有子文件夹及文件的数量
来源:Linux社区&
作者:sndapk
find命令查看(推荐):
所有子目录的数量:
[root@localhost ~]# find pma -type d | wc -l 125 [root@localhost ~]# find pma/ -type d | wc -l 125 [root@localhost ~]# find pma/* -type d | wc -l 124 --正确
结果不同的原因:[root@localhost ~]# find pma -type d | more pma --输出结果首行[root@localhost ~]# find pma/* -type d | more pma/examples --输出结果首行
总结:使用pma/*不包含pma这个父目录,只输出其下的子目录。
所有文件的数量:
[root@localhost ~]# find pma -type f | wc -l 987 [root@localhost ~]# find pma/ -type f | wc -l 987 [root@localhost ~]# find pma/* -type f | wc -l 987
tree命令查看(不推荐):
[root@localhost ~]# tree pma ……124 directories, 984 files -----------------------------------------[root@localhost ~]# tree pma/ ……&124 directories, 984 files
du命令查看:
[root@localhost ~]# du -ah pma/* | wc -l 1111
总结:du查看的结果为1111,子目录的数量为124,文件数量为:,所以tree命令查看的结果应该是不准确,至于少计算了哪个文件,没再查这个问题,推荐使用find命令查看。
相关资讯 & & &
& (08/17/:43)
& (08/14/:42)
& (05/18/:49)
& (06/07/:48)
& (07/04/:32)
& (03/25/:16)
   同意评论声明
   发表
尊重网上道德,遵守中华人民共和国的各项有关法律法规
承担一切因您的行为而直接或间接导致的民事或刑事法律责任
本站管理人员有权保留或删除其管辖留言中的任意内容
本站有权在网站内转载或引用您的评论
参与本评论即表明您已经阅读并接受上述条款在Linux下找出多个文件中最新的那个文件 - Bash @ Linux - ITeye技术网站
博客分类:
问:在Linux下怎么找出多个文件(比如*.cpp)中最新的那个文件?
答:可以采用如下命令形式
(1)将文件按从新到旧排列,取第一个。
ls -t *.cpp | head -1
(2)将文件按从旧到新排列,取最后一个。
ls -rt *.cpp | tail -1
执行示例:
[root@jfht synway]# ls -lrt *.cpp
-rw-r--r-- 1 root root
ch_set.cpp
-rw-r--r-- 1 root root -11-04 ssv_codec.cpp
-rw-r--r-- 1 root root
-04 main.cpp
-rw-r--r-- 1 root root
config.cpp
-rw-r--r-- 1 root root
-07 syn_thread.cpp
-rw-r--r-- 1 root root
ssv_server.cpp
-rw-r--r-- 1 root root
-07 ctsc_session.cpp
-rw-r--r-- 1 root root
-07 ctmc_session.cpp
-rw-r--r-- 1 root root -06-30 ch_info.cpp
从上面的输出来看,显然ch_info.cpp是最新的。
[root@jfht synway]# ls -t *.cpp | head -1
ch_info.cpp
[root@jfht synway]# ls -rt *.cpp | tail -1
ch_info.cpp
[root@jfht synway]#
编写成脚本执行,如下所示:
[root@jfht synway]# vi newest_file.sh
newest_file_of()
ls -t "$@" | head -1
echo "newest file of *.cpp is $(newest_file_of *.cpp)"
[root@jfht synway]# ./newest_file.sh
newest file of *.cpp is ch_info.cpp
[root@jfht synway]#
上述命令的详细解释:
按修改时间排序,较新的文件排在前面(sort by modification time),也就是按照从新到旧排序。如果要按照从旧到新排序,则需要增加-r参数(逆序)。
man ls 写道
use a long listing format
-r, --reverse
reverse order while sorting
sort by modification time
取第一行。也可以写作:head -n 1。
man head 写道
-n, --lines=[-]N
print the first N lines instead of the first 10; with the leading ‘-’, print all but the last N lines of each file
取最后一行。也可以写作:tail -n 1。
man tail 写道
-n, --lines=N
output the last N lines, instead of the last 10
本文链接:
浏览 10914
codingstandards
浏览: 3008949 次
来自: 上海
楼主咋没分析下源码呢?
tail -F 就可以吧
新手学习了,就是不明白为一个网卡配多个ip有什么用
不错,谢谢!
不错,谢谢!Linux命令行下查看某文件夹下的文件个数_Linux系统_ThinkSAAS
Linux命令行下查看某文件夹下的文件个数
Linux命令行下查看某文件夹下的文件个数
内容来源: 网络
Linux命令行下查看某文件夹下的文件个数
ls -l | grep &^-& | wc -l
ls -l 列出文件信息
grep &^-& 搜索一般文件,如果为grep &^d&则搜索目录
wc -l 统计个数
作者 ericchan2012
PHP开发框架
开发工具/编程工具
服务器环境}

我要回帖

更多关于 linux命令行删除文件 的文章

更多推荐

版权声明:文章内容来源于网络,版权归原作者所有,如有侵权请点击这里与我们联系,我们将及时删除。

点击添加站长微信