Skip to content

Instantly share code, notes, and snippets.

@changchichung
Last active July 10, 2023 07:15
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 changchichung/14c945c22a4909a544506602411fa790 to your computer and use it in GitHub Desktop.
Save changchichung/14c945c22a4909a544506602411fa790 to your computer and use it in GitHub Desktop.
replace last part of ip address to 0/24 to represent a Class C network

command

 | tr -d " " | sed 's/[0-9]*$/0\/24/'

result

echo "192.168.1.1" | tr -d " " | sed 's/[0-9]*$/0\/24/'
192.168.1.0/24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment