while IFS= read -r line
do
length=${#line}
if (($length<181)); then
continue
fi
str1=${line:115:2}
str2=${line:118:2}
str3=${line:121:2}
str4=${line:124:2}
str6="ext data"
str=$str4$str3$str2$str1
str7=${line:127:24}
printf "%s\t%s\t%s\n" "$str" "$str7" "$str6" >> ./test3.txt
echo $str
done < ./test2.txt
"IFS=" 表示将输入的行按原样传递给变量"line",不会去掉行首行尾的空格或制表符
"read"会从读取标准输入一行并存储到"line",使用"< ./test2.txt"重定向则会从文件一行一行读