码迷,mamicode.com
首页 > 系统相关 > 详细

shell 输出文件各行的长度

时间:2019-08-24 00:26:49      阅读:124      评论:0      收藏:0      [点我收藏+]

标签:length   pre   spl   color   span   code   $0   文件   ref   

 

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

 

shell 输出文件各行的长度

标签:length   pre   spl   color   span   code   $0   文件   ref   

原文地址:https://www.cnblogs.com/sea-stream/p/11403182.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!