shell脚本 逐行读取文本并且 进行字符串的截取
例如有个文本文件
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
浙公网安备 33010602011771号