等价于windows查找mac地址的命令
The equivalent windows command to find macaddress
我使用下面的 linux 命令来查找 macaddress
"ifconfig | grep enp0s20f6 | awk '{print }'"
查找 macaddress 的等效 windows 命令应该是什么?
我linux,使用grep和awk过滤ifconfig的结果。有没有办法修改等效的 windows 命令以仅获取 macaddress?
对于windows:
C:\>ipconfig /all
Windows IP Configuration
Host Name . . . . . . . . . . . . : PC-10234
Primary Dns Suffix . . . . . . . : mydomain.com
DNS Suffix Search List. . . . . . : mydomain.com
mydomain.com
Wireless LAN adapter Wireless Network Connection:
Connection-specific DNS Suffix . : mydomain.com
Description . . . . . . . . . . . : Intel(R) Centrino(R) Advanced-N 6205
Physical Address. . . . . . . . . : 3C-99-88-64-A1-F0
Ethernet adapter Local Area Connection:
Connection-specific DNS Suffix . : mydomain.com
Description . . . . . . . . . . . : Intel(R) 82579LM Gigabit Network Connection
Physical Address. . . . . . . . . : 73-2B-4F-D5-12-A0
C:\>
或者
C:\>getmac
Physical Address Transport Name
=============================================================================
2C-3F-45-02-1B-32 \Device\Tcpip_{7E49B486-120A-4BC2-2114-B345A4D5C5}
10-13-17-BC-12-48 Media disconnected
22-B3-C5-30-76-78 \Device\Tcpip_{213E8D2A-1DBE-4240-8301-BE6F3EACAF9D}
00-05-2A-3C-78-00 \Device\Tcpip_{F01E3FC2-A5A1-6940-D1A1-C7521AEC4296}
2C-23-45-14-23-AD Media disconnected
C:\>
有关更多详细信息,请访问此处 - get-mac-address-command-line
为了只获得 mac-地址,你可以做类似
的事情
for /f "usebackq tokens=3 delims=," %a in (`getmac /fo csv /v ^| find "Local Area Connection"`) do set MAC=%~a
展示美甲
for /F "delims=: tokens=2" %a IN ('netsh lan show interfaces^|findstr /C:"Physical address"') do @echo %a
如果您在批处理文件中使用它,则需要双倍的 %。
for /F "delims=: tokens=2" %%a IN ('netsh lan show interfaces^|findstr /C:"Physical address"') do @echo %%a
你可以用 ipconfig 做同样的事情,但是机器可以有 virtual\tunnel 个接口,ipconfig 会显示它们,这可能会导致额外的零行。
for /F "delims=: tokens=2" %%a IN ('ipconfig /all^|findstr /C:"Physical address"') do @echo %%a
找你MAC,只需要改变findstr的参数
我使用下面的 linux 命令来查找 macaddress
"ifconfig | grep enp0s20f6 | awk '{print }'"
查找 macaddress 的等效 windows 命令应该是什么?
我linux,使用grep和awk过滤ifconfig的结果。有没有办法修改等效的 windows 命令以仅获取 macaddress?
对于windows:
C:\>ipconfig /all
Windows IP Configuration
Host Name . . . . . . . . . . . . : PC-10234
Primary Dns Suffix . . . . . . . : mydomain.com
DNS Suffix Search List. . . . . . : mydomain.com
mydomain.com
Wireless LAN adapter Wireless Network Connection:
Connection-specific DNS Suffix . : mydomain.com
Description . . . . . . . . . . . : Intel(R) Centrino(R) Advanced-N 6205
Physical Address. . . . . . . . . : 3C-99-88-64-A1-F0
Ethernet adapter Local Area Connection:
Connection-specific DNS Suffix . : mydomain.com
Description . . . . . . . . . . . : Intel(R) 82579LM Gigabit Network Connection
Physical Address. . . . . . . . . : 73-2B-4F-D5-12-A0
C:\>
或者
C:\>getmac
Physical Address Transport Name
=============================================================================
2C-3F-45-02-1B-32 \Device\Tcpip_{7E49B486-120A-4BC2-2114-B345A4D5C5}
10-13-17-BC-12-48 Media disconnected
22-B3-C5-30-76-78 \Device\Tcpip_{213E8D2A-1DBE-4240-8301-BE6F3EACAF9D}
00-05-2A-3C-78-00 \Device\Tcpip_{F01E3FC2-A5A1-6940-D1A1-C7521AEC4296}
2C-23-45-14-23-AD Media disconnected
C:\>
有关更多详细信息,请访问此处 - get-mac-address-command-line
为了只获得 mac-地址,你可以做类似
的事情for /f "usebackq tokens=3 delims=," %a in (`getmac /fo csv /v ^| find "Local Area Connection"`) do set MAC=%~a
展示美甲
for /F "delims=: tokens=2" %a IN ('netsh lan show interfaces^|findstr /C:"Physical address"') do @echo %a
如果您在批处理文件中使用它,则需要双倍的 %。
for /F "delims=: tokens=2" %%a IN ('netsh lan show interfaces^|findstr /C:"Physical address"') do @echo %%a
你可以用 ipconfig 做同样的事情,但是机器可以有 virtual\tunnel 个接口,ipconfig 会显示它们,这可能会导致额外的零行。
for /F "delims=: tokens=2" %%a IN ('ipconfig /all^|findstr /C:"Physical address"') do @echo %%a
找你MAC,只需要改变findstr的参数