Back to Blog
How to view ipconfig on a mac7/3/2023 ![]() Using $(.) command substitution in order to have something to pass to ipconfig getifaddr I determine the Hardware Port's Device Name with the output of networksetup -listallhardwareports and pipe | it through awk which is looking for Hardware Port: Wi-Fi and uses the get line function, which reads the next line after the match and is passed to print $2, which in essence prints the second part of the line following the match, which in the case is en0 and that gets passed to ipconfig getifaddr as its argument in the first example, e.g ipconfig getifaddr en0. The relevant output of networksetup -listallhardwareports for my system is: Hardware Port: Wi-Fi If you just want to output the target device's IP Address to stdout, use the following example: $ ipconfig getifaddr $(networksetup -listallhardwareports | awk '/Hardware Port: Wi-Fi/'))" Networksetup -listallhardwareports shows for you. I have a MacBook Pro that doesn't have a built-in Ethernet Port so in my examples I'll use Hardware Port: Wi-Fi since I tested this in both examples below and it worked, however you can change it to Hardware Port: Ethernet if that is what the output of ![]() There may be several different ways to accomplish what you're asking, however, I'll just throw this out there.
0 Comments
Read More
Leave a Reply. |