001、
[root@pc1 test3]# ls test.txt [root@pc1 test3]# cat test.txt ## 测试数据 addg ad adfgg d dfg [root@pc1 test3]# awk '{print length}' test.txt 4 2 5 1 3
002、awk
[root@pc1 test3]# ls test.txt [root@pc1 test3]# cat test.txt addg ad adfgg d dfg [root@pc1 test3]# awk -F "" '{print NF}' test.txt ## awk实现 4 2 5 1 3
003、awk
[root@pc1 test3]# ls test.txt [root@pc1 test3]# cat test.txt ## 测试数据 addg ad adfgg d dfg [root@pc1 test3]# awk '{print gsub(/./,"&")}' test.txt ## awk实现 4 2 5 1 3