Skip to content

Instantly share code, notes, and snippets.

@Jaid
Last active June 11, 2022 15:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Jaid/ad1f37954cbe8958e95090c0b2f085a8 to your computer and use it in GitHub Desktop.
Save Jaid/ad1f37954cbe8958e95090c0b2f085a8 to your computer and use it in GitHub Desktop.
Get local IPv4 address programmatically on Windows (using Bash and Node)

Get local IPv4 address programmatically on Windows (using Bash and Node)

Requirements:

  • Any shell
  • Node
ip=$(node -e "process.stdout.write(/(?<ip>\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})\(Preferred\)/.exec(\`$(ipconfig -all)\`).groups.ip)")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment