免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 2343 | 回复: 7
打印 上一主题 下一主题

请教:怎样在一个文件中每隔一行就插入两行字母 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2006-07-06 19:47 |只看该作者 |倒序浏览
比如
把下列文件
TransactionGCTest
TransactionIdTest
TransactionListTest
变成
test=
     /root/TransactionGCTest
test=
     /root/TransactionIdTest
test=
     /root/TransactionListTest


非常感谢

论坛徽章:
0
2 [报告]
发表于 2006-07-06 19:50 |只看该作者
比如
把下列文件
TransactionGCTest
TransactionIdTest
TransactionListTest
变成
test=
     /root/TransactionGCTest
test=
     /root/TransactionIdTest
test=
     /root/TransactionListTest


非常感谢

论坛徽章:
0
3 [报告]
发表于 2006-07-06 21:22 |只看该作者
while read Line;
do
echo "test="
echo “/root/$Line"
done < file.dat

$cat file.dat
TransactionGCTest
TransactionIdTest
TransactionListTest


没测试,应该可以吧?

[ 本帖最后由 phpman 于 2006-7-6 21:23 编辑 ]

论坛徽章:
1
荣誉版主
日期:2011-11-23 16:44:17
4 [报告]
发表于 2006-07-06 21:50 |只看该作者
try this:
sed 's:^:  /root/:' 1.txt | sed '1,$ itest='

论坛徽章:
0
5 [报告]
发表于 2006-07-06 21:58 |只看该作者
awk '{printf "test=\n          /root/%s\n",$0}' urfile

[ 本帖最后由 林子 于 2006-7-6 22:00 编辑 ]

论坛徽章:
1
荣誉会员
日期:2011-11-23 16:44:17
6 [报告]
发表于 2006-07-07 01:33 |只看该作者

  1. sed -e 's/^/    \/root\//' -e '1,$itest='
复制代码

论坛徽章:
1
荣誉会员
日期:2011-11-23 16:44:17
7 [报告]
发表于 2006-07-07 10:58 |只看该作者
sed 's/^/test=\n\t\/root\//'

论坛徽章:
0
8 [报告]
发表于 2006-07-07 11:27 |只看该作者
sed 'itest=
s:^:     /root/:' a
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP