shell批量处理

来源:互联网 发布:linux vi 跳到最后 编辑:程序博客网 时间:2024/06/06 14:18

将以下字符串

fat110abccafat136bcdfgfat123hell0fat122world1

转为如下形式

fat110=abccafat136=bcdfgfat123=hell0fat122=world1

方法如下:

[root@iZ23hh6yk41Z test]# cat test.txt |xargs -n 2|tr ' ' '='[root@iZ23hh6yk41Z test]# cat test.txt |xargs -n 2|awk 'BEGIN{RS=" ";ORS="="}{print}' [root@iZ23hh6yk41Z test]# sed 'N;s#\n#=#g' test.txt[root@iZ23hh6yk41Z test]# while read line;do if [ $(echo $line|grep fat|wc -l) -ne 1 ];then echo =$line;else echo -n $line;fi;done < test.txt

这里写图片描述

原创粉丝点击