首页 > 系统服务 > 详细

shell脚本 逐行读取文本并且 进行字符串的截取

时间:2016-03-22 13:54:47      阅读:1181      评论:0      收藏:0      [点我收藏+]

 

例如有个文本文件

1234  ji

adfa jiji

adfasd qqwe

    // 注意一定要有个回车,这样脚本才会读到最后一行 

 

while read typeline
do 
#get line txt
typeInf=$typeline
#get type
#去除右边第一个空格开始的后边所有字符
typetmp=${typeInf%% *}
#judge type same
if [ "$typetmp" = "$type" ]
then
echo sametype:$typetmp
#get count
pcount=${typeInf:0-1}
fi
done < $file

  

 

shell脚本 逐行读取文本并且 进行字符串的截取

原文:http://www.cnblogs.com/ZhenShi/p/5306074.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!