我有一个名为“namelist.txt”与电子邮件地址输入文件:读取输入文件,插入文本输出文件
[email protected]
[email protected]
[email protected]
我试图读取该输入文件中的地址,将其价值的应该读输出文件(newfile.txt):
user "[email protected]" with pass"pass" is "[email protected]" here
user "[email protected]" with pass"pass" is "[email protected]" here
user "[email protected]" with pass"pass" is "[email protected]" here
我来最接近的是用awk:
awk '{print "user $0 there with pass"pass" is user $0 here"}' <namelist.txt> newfile.txt
然而,这打印如下:
user $0 there with pass is user $0 here
user $0 there with pass is user $0 here
user $0 there with pass is user $0 here
这不打印变量值,也不是“通”值。
我不知道我错了,还是我甚至在正确的轨道,所以任何意见和/或指针将不胜感激。
编辑:
使用:
awk '{print "user \""$0"\" there with pass \"pass\" is user \""$0"\" here}' file
导致在Ubuntu(14.04.2 LTS)以下输出:
“heree与通 ”合格“ 是用户” USER1 @ domain.com
“heree with pass”pass“is user”[email protected]
“heree with pass”pass“is user”[email protected]
上述代码工作正常在UNIX终端而不在Ubuntu也不树莓裨。
我很困惑,为什么发行版之间的差异。
感谢您的快速回复。我想我可能还有其他问题。当我在联机unix终端中尝试你的答案时,它的工作原理非常完美。然而,当我尝试在Ubuntu(或Raspi)我得到不同的结果:“heree与通”通”是用户‘[email protected] ’heree与通‘通’是用户‘[email protected] ’heree与通“通”是用户“[email protected] – hibbijibbies
显示在您的文章你格式化文本的任何问题,这是不可能的阅读和猜你在评论中写的是什么格式。 – 123
对不起。我编辑了原文,以反映我尝试使用您的答案。 – hibbijibbies