处理 行首空格 行尾空格 空行
去行首的空格/双引号
sed 's/^[ \t]*//g' sed 's/^"*//g'
去掉行尾的空格/双引号
sed 's/[ \t]*$//g' sed 's/"*$//g'
去掉空行
grep -v "^$"
循环之美
文件中每行是单个字符串:
transation_list=`cat ${USER}.transation_ID.record.txt` for i in ${transation_list} do echo ${i} done
文件中每行是几个字符串组:
cat ${USER}.${i}.file_list.txt | while read line do echo ${line} >> ${USER}_detail_info.txt FILE=`echo ${line}| cut -d " " -f 1` VERSION=`echo ${line}| cut -d " " -f 2` echo FILE is ${FILE} >> ${USER}_detail_info.txt echo VERSION is ${VERSION} >> ${USER}_detail_info.txt done
字符串转数字运算:
lines_total_=`cat ${USER}.${i}.lines.txt ` lines_total_all=`expr $lines_total_all + $lines_total_`
No Leanote account? Sign up now.