linux中如何统计文件字符数

1、测试数据

root@PC1:/home/test2# ls
test.txt
root@PC1:/home/test2# cat test.txt
a 3 5 d
s g e z
root@PC1:/home/test2# cat -A test.txt
a 3 5 d$
s g e z$

 

2、wc -c

root@PC1:/home/test2# ls
test.txt
root@PC1:/home/test2# cat test.txt
a 3 5 d
s g e z
root@PC1:/home/test2# cat -A test.txt
a 3 5 d$
s g e z$
root@PC1:/home/test2# wc -c test.txt  ## 每一行8个字符,包含了空格和末尾的换行符
16 test.txt

 

posted @ 2022-01-30 23:22  小鲨鱼2018  阅读(359)  评论(0编辑  收藏  举报