shell 输出文件各行的长度

 

test.sh

#!/bin/bash
string="hello,shell,split,test"
array=(${string//,/ })

for var in ${array[@]}
do
   echo $var
done

输出

bogon:conf macname$ awk '{print length($0)}' test.sh 
11
33
24
1
22
2
12
4

 

 

参考:

https://www.jb51.net/article/121290.htm

 

posted @ 2019-08-23 23:35  anobscureretreat  阅读(1137)  评论(0编辑  收藏  举报