我正在尝试使用awk将/ 32附加到文件中的公共IP上
ip.txt的IP地址为4.14.XX.XXX
问题出在脚本文件中的命令
awk "{print $0 "/32"}" < ip.txt
result = 0.129375
如果我删除/
的结果不是4.14.XX.XXX32
我想要4.14.XX.XXX/32.
完整的蝙蝠文件
curl v4.ifconfig.co > ip.txt
awk "{ print $0 "/32" }" < ip.txt > ipnew.txt
@REM set stuff=type ipnew.txt
for /f %%i in ('type ipnew.txt') do set stuff=%%i
echo %stuff%
===================
awk -f changeipaddress.bat
错误
awk: changeipaddress.bat:1: curl v4.ifconfig.co > ip.txt
awk: changeipaddress.bat:1: ^ syntax error
awk: changeipaddress.bat:1: curl v4.ifconfig.co > ip.txt
awk: changeipaddress.bat:1: ^ syntax error
awk: changeipaddress.bat:2: awk "{ print $0 "/32" }" < ip.txt > ipnew.txt
awk: changeipaddress.bat:2: ^ syntax error
awk: changeipaddress.bat:2: awk "{ print $0 "/32" }" < ip.txt > ipnew.txt
awk: changeipaddress.bat:2: ^ syntax error
awk: changeipaddress.bat:3: @REM set stuff=type ipnew.txt
awk: changeipaddress.bat:3: ^ invalid char '@' in expression
请建议我要去哪里错了?
关于, TJ。
答案 0 :(得分:1)
创建一个内容为#define POWER_OF_TW0(x) ( ((x) != 0u) && (!((unsigned)(x)&((unsigned)(x) - 1u))))
的名为foo.awk
的文件(即awk脚本),然后将bat文件的第2行从{ print $0 "/32" }
更改为awk "{ print $0 "/32" }" < ip.txt > ipnew.txt
。现在,以正常方式运行您的bat文件。