shell:
cat tvm.sh
#!/bin/sh
echo "[/opt/download:/opt/tvmcap]" >/opt/script/channels.list
for channels in `cat /root/channel.txt|awk ‘{print $2}‘`
do
echo "wx.service.live.tvmining.com|shanghaidx|$channels|ipad|180" >>/opt/script/channels.list
echo "wx.service.live.tvmining.com|shanghaidx|$channels|ipsd|180" >>/opt/script/channels.list
echo "wx.service.live.tvmining.com|shanghaidx|$channels|iptv|180" >>/opt/script/channels.list
done
python:
[root@localhost ~]# cat test.txt
#!/usr/bin/env python
f1=open(‘channel.txt‘,‘r‘)
f2=open(‘channel.list‘,‘w+‘)
for line in f1.readlines():
tmp = line.split()
print >>f2, "wx.server.live.tvmining.com|test|%s|ipad|180" % tmp[1]
print >>f2, "wx.server.live.tvmining.com|test|%s|ipsd|180" % tmp[1]
print >>f2, "wx.server.live.tvmining.com|test|%s|iptv|180" % tmp[1]
f2.close
f1.close
两种方法 大家可以任选其一 这两个脚本我都是在线上用到的 没有问题
本文出自 “linuxyy” 博客,请务必保留此出处http://linuxyy.blog.51cto.com/9490250/1625786
一个文件的某一列写入到另一个文件的行中shell与python
原文:http://linuxyy.blog.51cto.com/9490250/1625786