就是用bat脚本
修改配置文件c:\zabbix\conf\zabbix_agentd.win.conf
修改一下Hostname项:
Hostname=(自提柜ID)
替换配置文件
bat替换文件内容
答案:2 悬赏:10 手机版
解决时间 2021-02-01 03:40
- 提问者网友:趣果有间
- 2021-01-31 06:35
最佳答案
- 五星知识达人网友:怙棘
- 2021-01-31 08:02
@echo off
setlocal enabledelayedexpansion
pushd c:\zabbix\conf\
for /f tokens^=1^,2^ delims^=^"^" %%a in ('wmic nicconfig get IPAddress /value ^| findstr /i "IPAddress=[^]"') do set ip=%%b
(for /f "tokens=*" %%i in (zabbix_agentd.win.confa.txt) do (
set s=%%i
for /f "tokens=1 delims==" %%j in ('echo !s!') do (
if /i "%%j"=="hostname" set s=Hostname=%ip%
echo !s!)))>temp.txt
move /y temp.txt zabbix_agentd.win.conf
setlocal enabledelayedexpansion
pushd c:\zabbix\conf\
for /f tokens^=1^,2^ delims^=^"^" %%a in ('wmic nicconfig get IPAddress /value ^| findstr /i "IPAddress=[^]"') do set ip=%%b
(for /f "tokens=*" %%i in (zabbix_agentd.win.confa.txt) do (
set s=%%i
for /f "tokens=1 delims==" %%j in ('echo !s!') do (
if /i "%%j"=="hostname" set s=Hostname=%ip%
echo !s!)))>temp.txt
move /y temp.txt zabbix_agentd.win.conf
全部回答
- 1楼网友:西风乍起
- 2021-01-31 08:07
@echo off
setlocal enabledelayedexpansion
set fn=1.txt
(for /f "tokens=*" %%i in (%fn%) do (
set s=%%i
set s=!s:789=aaa!
echo !s!))>temp.txt
move /y temp.txt "%fn%"
如果修改当前目录下所有txt
@echo off
setlocal enabledelayedexpansion
for /f "tokens=*" %%a in ('dir/b *.txt') do (
(for /f "tokens=*" %%i in (%%a) do (
set s=%%i
set s=!s:789=aaa!
echo !s!))>temp.txt
move /y temp.txt "%%a" )
如果可以用第三方工具的话,推荐国产高手白杨的wfr,命令非常简单
wfr 1.txt -r:"789" -t:"aaa"
替换所有txt
wfr *.txt -r:"789" -t:"aaa"
我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯