2023年8月2日发(作者:)
shell中使⽤awk判断⽂件中字段的值并进⾏替换的⽅法stime=`date +%s`#获取当前时间echo 开始处理⽂件: B08101007_${month_id}.#处理⽂件zcat | awk -F 'x01' '{#压缩⽂件查看⽅式使⽤zcat,分隔符为'X01' if($2 == 822) {n2="V0511300"}#判断第⼆个字段值是否是822,如果是替换成V0511300 else if($2 == 833) {n2="V0511100"} else if($2 == 811) {n2="V0513100"} else if($2 == 832) {n2="V0511000"} else if($2 == 818) {n2="V0510300"} else {n2=""}#其他输出为空#根据获取到的值重新输出到新⽂件 etime=`date +%s`s=`echo "scale=0; ($etime - $stime)%60" | bc`m=`echo "scale=0; ($etime - $stime)/60%60" | bc`h=`echo "scale=0; ($etime - $stime)/60/60" | bc`echo 处理⽂件结束: `date +"%F %T"` end 耗时 $h ⼩时 $m 分钟 $s 秒};{print $1"x01"n2"x01"$3"x01"$4"x01"$5"x01"$6"x01"$7"x01"$8"x01"$9"x01"$10"x01"$11"x01"$12"x01"$13"x01"$14"x01"$15}'>/mnt/sd03/data/sichuan/
发布者:admin,转转请注明出处:http://www.yc00.com/xiaochengxu/1690920328a463760.html
评论列表(0条)