首页 > 系统相关 >linux 中统计文件的行数,不显示文件名

linux 中统计文件的行数,不显示文件名

时间:2022-12-08 23:44:46浏览次数:41  
标签:10 文件名 PC1 cat 行数 linux test txt root

 

001、cat + wc -l

[root@PC1 test]# ls
a.txt
[root@PC1 test]# cat a.txt              ## 测试文件
1
2
3
4
5
6
7
8
9
10
[root@PC1 test]# cat a.txt | wc -l     ## 输出文件的行数
10

 

 

002、sed -n "$=" 

[root@PC1 test]# ls
a.txt
[root@PC1 test]# cat a.txt
1
2
3
4
5
6
7
8
9
10
[root@PC1 test]# sed -n "$=" a.txt    ## 统计文件的行数,不显示文件名
10

 

 

003、wc -l <file

[root@PC1 test]# ls
a.txt
[root@PC1 test]# cat a.txt
1
2
3
4
5
6
7
8
9
10
[root@PC1 test]# wc -l <a.txt      ## 输出文件的行数
10

 

标签:10,文件名,PC1,cat,行数,linux,test,txt,root
From: https://www.cnblogs.com/liujiaxin2018/p/16967749.html

相关文章

  • Linux安装ffmpeg
    使用的机器是Ubuntu18.04下载安装环境进入官网http://ffmpeg.org/点击Download,找到适用自身系统的下载包,我这里下载的Ubuntu-Officialpackages得到一个ffmpeg_x.x.x.......
  • linux中条件分支 逻辑而且 和 或者
     001、-a表示而且[root@PC1test]#a=5[root@PC1test]#b=10[root@PC1test]#if[$a-gt0-a$b-gt0];thenecho"yes";fi##-a表示逻辑而且,只有两......
  • linux 中 如何判断文件夹是否为空
     001、[root@PC1test]#ls[root@PC1test]#mkdirtest1test2##测试文件夹[root@PC1test]#echo"xxx">test2/a.txt[root@PC1test]#lste......
  • linux 中判断变量是否已经赋值
     001、[root@PC1test]#a=10[root@PC1test]#echo$a10[root@PC1test]#echo$b[root@PC1test]#[-z$a]##如果变量没有被赋值,则返回真,否则返回......
  • 期末复习-操作系统与linux管理
    liunx操作系统第一章操作系统引论p2-p51.什么是操作系统操作系统是管理和控制着计算机系统中的各种软硬件资源,合理地组织计算机的工作流程,为用户使用计算机提供接口......
  • linux 中判断文件是否为空
     001、[root@PC1test]#ls[root@PC1test]#toucha.txt##测试文件[root@PC1test]#seq6>b.txt##测试文件[root@PC1test]#ca......
  • Linux日志审计
    本文为joshua317原创文章,转载请注明:转载自joshua317博客 https://www.joshua317.com/article/291常用命令find、grep、egrep、awk、sedLinux中常见日志以及位置/v......
  • linux编译安装时常见错误解决办法
     linux编译安装时常见错误解决办法configure:error:xslt-confignotfound.Pleasereinstallthelibxslt>=1.1.0distribution复制代码代码如下:yum-yinstallli......
  • Linux如何查看服务启动状态是否开机自动启动
    本文为joshua317原创文章,转载请注明:转载自joshua317博客 https://www.joshua317.com/article/284方式一chkconfiglinux中查看服务启动状态是否开机自动启动的方法:1......
  • Linux系统的开机自启动
    本文为joshua317原创文章,转载请注明:转载自joshua317博客 https://www.joshua317.com/article/285当你使用windows操作系统时,开机后总会有各种软件自我启动完成,你并没有......