阅读:2191回复:1
请问谁可以写一个bash脚本实现以下功能?
处理一个文本文件abc.txt,输出一个文本文件abc.bat
例如:abc.txt的内容如下: #Org Group Emp. No. Org Structure Global ID Org Name ESN Number Dept Code #GLO&GBO 1596843 SPENSER WILLIAMS,GLO&GBO GLO&GBO 554-8366 G800 autodesk DES 1361449 RICK LI,autodesk DES 1361449 autodesk DES 554-8300 G500 autodesk SV 11274 JIMMY LU,autodesk SV No23077 autodesk SV 8803 G512 autodesk DES 11451 STANLEY ZHU,autodesk DES No23447 autodesk DES 554-8500 G592 #********************************** #Org Group Emp. No. Org Structure Global ID Org Name ESN Number Dept Code #GLO&GBO 1596843 SPENSER WILLIAMS,GLO&GBO GLO&GBO 554-8366 G800 autodesk DES 1361449 RICK LI,autodesk DES 1361449 autodesk DES 554-8300 G500 autodesk SV 10927 JACK XU,autodesk SV No15676 autodesk SV 554-8804 G511 输出如下; #Org Group Emp. No. Org Structure Global ID Org Name ESN Number Dept Code #GLO&GBO 1596843 SPENSER WILLIAMS,GLO&GBO GLO&GBO 554-8366 G800 #autodesk DES 1361449 start C:\abc\pro.exe RICKLI #autodesk DES 1361449 autodesk DES 554-8300 G500 #autodesk SV 11274 start C:\abc\pro.exe JIMMYLU #autodesk SV No23077 autodesk SV 8803 G512 #autodesk DES 11451 start C:\abc\pro.exe STANLEYZHU #autodesk DES No23447 autodesk DES 554-8500 G592 #********************************** #Org Group Emp. No. Org Structure Global ID Org Name ESN Number Dept Code #GLO&GBO 1596843 SPENSER WILLIAMS,GLO&GBO GLO&GBO 554-8366 G800 #autodesk DES 1361449 start C:\abc\pro.exe RICKLI #autodesk DES 1361449 autodesk DES 554-8300 G500 #autodesk SV 10927 start C:\abc\pro.exe JACKXU #autodesk SV No15676 autodesk SV 554-8804 G511 具体说明: 1.对于以#开头的行不做任何处理,对于以特定字符“Org”“GLO”等开头的行加#号 2.字段以空格为单位 3.在第3字段后换行,在前面加入#号 4.第4字段和第5字段合并,删除中间空格,并且在前面加入字符串 “start C:\abc\pro.exe ” 5.去掉第5字段后的逗号,并且换行,新行前面加#号 |
|
|
沙发#
发布于:2008-05-10 21:03
综合运用awk,sed等脚本工具和正则表达时,可以做到
|
|
|