linux 中同时统计文件的行数和列数

 

1、测试数据

[root@centos7 test4]# ls
test.txt
[root@centos7 test4]# cat test.txt
d j k j
x m y e
s g j i
x v b d
z c e t

 

2、统计行数和列数

[root@centos7 test4]# ls
test.txt
[root@centos7 test4]# cat test.txt
d j k j
x m y e
s g j i
x v b d
z c e t
[root@centos7 test4]# awk '{i++} END {print FILENAME, i, NF}' test.txt  ## 5行4列
test.txt 5 4

 

posted @ 2022-04-14 14:52  小鲨鱼2018  阅读(389)  评论(0编辑  收藏  举报