我有一个包含一些文本的文件,例如:text.txt:
value1
value2
value3
value4
我想制作一个脚本,创建一个名称格式为name_of_file_value1_python.py
的文件,其中包含以下几行:
#!/usr/bin/python2.6
url = "http://example.com/abc/get?value=value1"
print "count.value1",data['total']
答案 0 :(得分:2)
while read i; do printf '#!/usr/bin/python2.6\n\nurl = "http://example.com/abc/get?value='$i'"\nprint "count.'$i'",data["total"]' > name_of_file_${i}_python.py; done < text.txt