Skip to content

Instantly share code, notes, and snippets.

@afeld
Created July 9, 2018 06:39
Show Gist options
  • Save afeld/e53ac65e122ccd27547f2d2a54755f8b to your computer and use it in GitHub Desktop.
Save afeld/e53ac65e122ccd27547f2d2a54755f8b to your computer and use it in GitHub Desktop.
redact IP addresses in output

When running a command with output that will be publicly available, you may not want to show IP addresses. This might come up with output from a freemium continuous integration (CI) service like TravisCI or CircleCI, for example. Pipe output into the following command to redact the first three segments:

sed -E 's/[0-9]+\.[0-9]+\.[0-9]+\.([0-9]+)/███.███.███.\1/g'

The squares are the Unicode "full block" character. Example use:

$ ansible-playbook -i digital_ocean.py --list-hosts playbooks/test.yml | sed -E 's/[0-9]+\.[0-9]+\.[0-9]+\.([0-9]+)/███.███.███.\1/g'

playbook: playbooks/test.yml

  play #1 (all): all	TAGS: []
    pattern: ['all']
    hosts (9):
      ███.███.███.190
      ███.███.███.217
      ███.███.███.45
      ███.███.███.36
      ███.███.███.190
      ███.███.███.126
      ███.███.███.29
      ███.███.███.171
      ███.███.███.201
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment