免费注册 查看新帖 |

Chinaunix

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

[文本处理] for 或者while [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2012-11-07 22:22 |只看该作者 |倒序浏览

a.txt里面有以下内容:

user1,your password is:
user2,your password is:
user3,your password is:


b.txt里面有以下内容:
abc123
123123
dddddd

想要把b.txt里面的内容(password)分别加到a.txt后面。
如:
user1,your password is:abc123
user2,your password is:123123
user3,your password is:dddddd

求助、、、感谢。

论坛徽章:
5
亥猪
日期:2013-10-15 13:41:04CU十二周年纪念徽章
日期:2013-10-24 15:41:34申猴
日期:2013-10-28 10:55:45辰龙
日期:2013-10-31 13:29:29丑牛
日期:2014-02-14 11:25:54
2 [报告]
发表于 2012-11-07 22:46 |只看该作者
paste file1 file2

论坛徽章:
5
未羊
日期:2014-08-04 16:15:21天秤座
日期:2014-08-13 13:52:372015年辞旧岁徽章
日期:2015-03-03 16:54:152015年迎新春徽章
日期:2015-03-04 09:56:112015亚冠之浦和红钻
日期:2015-06-29 15:30:48
3 [报告]
发表于 2012-11-07 22:46 |只看该作者
  1. paste -d “ ” a.txt b.txt
复制代码

论坛徽章:
0
4 [报告]
发表于 2012-11-07 23:03 |只看该作者
回复 3# dn833


   
抱歉,user1,your password is 的前面还有两行。
line 1.、。。。。
line 2。。。。。。
user1,your password is

line 1.、。。。。
line 2。。。。。。
user2,your password is

line 1.、。。。。
line 2。。。。。。
user3,your password is

论坛徽章:
3
2015年辞旧岁徽章
日期:2015-03-03 16:54:152015年迎新春徽章
日期:2015-03-04 09:51:162015年亚洲杯之阿曼
日期:2015-04-07 20:00:59
5 [报告]
发表于 2012-11-07 23:22 |只看该作者
提示: 作者被禁止或删除 内容自动屏蔽

论坛徽章:
0
6 [报告]
发表于 2012-11-07 23:26 |只看该作者
回复 5# zooyo

实在抱歉,辛苦老大了。我没表达清楚 。以下是全的。

a文件:
dn: cn=guest08,ou=dq,ou=customer,dc=domain,dc=com
changetype: modify
replace: userPassword
userPassword: 123123

dn: cn=guest09,ou=dq,ou=customer,dc=domain,dc=com
changetype: modify
replace: userPassword
userPassword: 123123

dn: cn=guest10,ou=dq,ou=customer,dc=domain,dc=com
changetype: modify
replace: userPassword
userPassword: 123123

   
b文件:
xdsfsd
edeo9
adfadf


想要把b文件的三个密码从上到下,分别替换掉a文件的123123。

非常感谢。

论坛徽章:
5
未羊
日期:2014-08-04 16:15:21天秤座
日期:2014-08-13 13:52:372015年辞旧岁徽章
日期:2015-03-03 16:54:152015年迎新春徽章
日期:2015-03-04 09:56:112015亚冠之浦和红钻
日期:2015-06-29 15:30:48
7 [报告]
发表于 2012-11-07 23:38 |只看该作者
  1. [root@12 bin]# cat a.txt
  2. line 1.....
  3. line 2......
  4. user1,your password is
  5. line 1.....
  6. line 2......
  7. user2,your password is
  8. line 1.....
  9. line 2......
  10. user3,your password is
  11. [root@12 bin]# cat b.txt
  12. bc123
  13. 123123
  14. dddddd
  15. [root@12 bin]# awk 'NR%3==0{getline f2 < "b.txt"; print $0" "f2}' a.txt
  16. user1,your password is bc123
  17. user2,your password is 123123
  18. user3,your password is dddddd
复制代码
是这个意思???

论坛徽章:
0
8 [报告]
发表于 2012-11-07 23:41 |只看该作者
回复 7# dn833

对,感谢。

   

论坛徽章:
0
9 [报告]
发表于 2012-11-07 23:45 |只看该作者
回复 7# dn833


line 1.....
line 2......
user1,your password is abcabc
line 1.....
line 2......
user2,your password is sdfdsd
line 1.....
line 2......
user3,your password is 1efsdfd


是这个意思。带line1 和line2的

论坛徽章:
3
2015年辞旧岁徽章
日期:2015-03-03 16:54:152015年迎新春徽章
日期:2015-03-04 09:51:162015年亚洲杯之阿曼
日期:2015-04-07 20:00:59
10 [报告]
发表于 2012-11-07 23:50 |只看该作者
提示: 作者被禁止或删除 内容自动屏蔽
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

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

清除 Cookies - ChinaUnix - Archiver - WAP - TOP