sed 变量替换 把m.txt文件中的$i替换成$j
zabbix:/root/zabbix# cat a1.sh for j in {1..48} do sed "s/\$i/$j/g" m.txt >>tmp.txt done You have new mail in /var/spool/mail/root zabbix:/root/zabbix# cat m.txt | head -20 <item> <name>192.168.4.1-G1/0/$i-in</name> <type>4</type> <snmp_community>zhuyou</snmp_community> <multiplier>1</multiplier> <snmp_oid>interfaces.ifTable.ifEntry.ifInOctets.$i</snmp_oid> <key>1.3.6.1.2.1.2.2.1.10.$i</key> <delay>30</delay> <history>90</history> <trends>365</trends> <status>0</status>