No description
  • Go 34.6%
  • Perl 32.8%
  • Shell 32.2%
  • Makefile 0.4%
Find a file
Heiko Schlittermann (HS12-RIPE) 0039ba1486
Some checks failed
/ release (push) Failing after 5s
ci: release
2026-05-02 23:29:14 +02:00
.forgejo/workflows ci: release 2026-05-02 23:29:14 +02:00
ai feat: switch AI variant to direct HTTP API with marker extraction 2026-04-23 23:37:18 +02:00
packaging new: add Debian and RPM packaging templates 2026-04-27 15:25:32 +02:00
perl chg: add Apache-2.0 license and headers to all source files 2026-04-23 21:42:40 +02:00
.gitignore chg: build into out/ directory, ignore out/ instead of binary name 2026-04-23 22:15:47 +02:00
.gogogo.conf ci: release 2026-05-02 23:29:14 +02:00
CLAUDE.md docs: add Debian/RPM packaging to release process 2026-04-27 15:28:02 +02:00
go.mod Initial implementation of grip 2026-04-23 13:25:34 +02:00
go.sum go: sum 2026-04-30 19:25:58 +02:00
ip.go chg: add Apache-2.0 license and headers to all source files 2026-04-23 21:42:40 +02:00
ip_test.go chg: add Apache-2.0 license and headers to all source files 2026-04-23 21:42:40 +02:00
LICENSE.txt chg: add Apache-2.0 license and headers to all source files 2026-04-23 21:42:40 +02:00
main.go chg: add Apache-2.0 license and headers to all source files 2026-04-23 21:42:40 +02:00
parse.go chg: add Apache-2.0 license and headers to all source files 2026-04-23 21:42:40 +02:00
parse_test.go chg: add Apache-2.0 license and headers to all source files 2026-04-23 21:42:40 +02:00
README.md feat: support multiple IPs/CIDRs per line in search and remove 2026-04-23 21:34:41 +02:00

grip

Search and manage IP address list files.

grip finds files that contain a given IP address — either as a literal host entry or because it falls inside a listed CIDR block. A companion remove subcommand deletes the address from matching files in-place, automatically splitting any CIDR that would otherwise swallow it.

Both IPv4 and IPv6 are supported throughout.

File format

One or more entries per line. Each entry is either:

  • a host address: 192.168.0.1, ::1
  • a CIDR block: 192.168.0.0/24, 2001:db8::/32

Multiple entries on the same line may be separated by any non-IP characters (commas, semicolons, spaces, tabs, etc.):

# production edge nodes
203.0.113.10
203.0.113.11

# lab range
198.51.100.0/24

# mixed — comma-separated
10.0.0.1, 10.0.0.2, 192.168.0.0/24

Comments (leading #) and blank lines are preserved unchanged.

Installation

go install go.schlittermann.de/heiko/grip@latest

Or build from source:

git clone git@git.schlittermann.de:heiko/grip.git
cd grip
go build -o grip .

Usage

grip [search] [-r] <ip> <path>...
grip remove  [-r] [-backup[=suffix]] <ip> <path>...

search is the default subcommand and can be omitted.

Options

Flag Applies to Description
-r both Recurse into directories
-backup[=suffix] remove Back up each modified file before changing it; suffix is appended to the filename (default .bak)

Prints every matching line in grep style (file:line: content):

$ grip 198.51.100.5 /etc/ipsets/
/etc/ipsets/lab.txt:4: 198.51.100.0/24

Exit status is non-zero when the address is not found in any file.

Remove

Removes the address from every file that contains it. If the address is covered by a CIDR, the CIDR is replaced by the minimal set of sub-CIDRs that covers the original range minus the single address:

$ grip remove 198.51.100.5 /etc/ipsets/lab.txt
/etc/ipsets/lab.txt:4: 198.51.100.0/24 -> [198.51.100.0/29, 198.51.100.4/32, 198.51.100.6/31, ...]

With -backup, the original file is preserved before modification:

# keeps lab.txt.bak
grip remove -backup 198.51.100.5 /etc/ipsets/lab.txt

# keeps lab.txt.orig
grip remove -backup=.orig 198.51.100.5 /etc/ipsets/lab.txt

Recursive search across a directory tree

grip -r 10.0.0.1 /etc/ipsets/

Running the tests

go test ./...

Repository layout

.            Go implementation (this README, go.mod, *.go)
perl/        Perl implementation — see perl/README.md
perl/t/      Perl test suite (run with: prove perl/t/)

Versioning

Both implementations share a single version tag vX.Y.Z. They are always released together and kept in sync.