sed命令未从文件中读取值
with open('file.txt') as f:
content = f.read()
subprocess.call("sed -i '/name/s/$/%s /' copy_vmlist" % content ,shell=True)
上面的一个不起作用。sed命令应该在copy\vmlist中搜索“name”,并将file.txt的内容(jega)附加到下一个colmun
Content of file.txt:
jega
Content of copy_vmlist:
Age
name
degree
Expected output in copy_vmlist:
Age
name jega
degree
问题出在sed命令参数中。我猜您想将“copyvmulist”文件中的“name”字符串替换为“jega”。试试看:
编辑:
编辑后,您需要:
相关问题 更多 >
编程相关推荐