Sort the neighbor table by interface and reachability state
Build a paste-ready command, then review its compatibility and effects before running it.
ip -j neigh show | jq -r '.[] | [.dev,.dst,(.lladdr // "-"),(.state[0] // "UNKNOWN")] | @tsv' | sortread-onlyno known side effects Compatibility
LinuxVerified for Linux using bash, zsh syntax.
Operational knowledgereview due 2027-01-19
Requirementsipip must be installed and available on PATH.
Version supportip Current supported releasesVerified for linux using bash, zsh syntax; consult compatibility notes for platform-specific differences.
Expected signalseth0 192.168.1.1 00:11:22:33:44:55 REACHABLERepresentative successful output; values vary with the selected target and system state.
Known errorsip: command not foundip is missing or is not available on PATH.
Verifyip -j neigh show | jq -r '.[] | [.dev,.dst,(.lladdr // "-"),(.state[0] // "UNKNOWN")] | @tsv' | sortThe output matches the expected target and exits without an error.Rollback noteNot required: this command is read-only and does not change system state.
Command breakdown
01ipCommandRuns the ip stage of this one-liner.
02-jOptionConfigures ip with the -j option.
03neighArgumentPasses neigh to ip.
04showArgumentPasses show to ip.
05|PipelinePasses the output on the left to the command on the right.
06jqCommandRuns the jq stage of this one-liner.
07-rOptionEnables raw, recursive, or reverse mode for this command.
08'.[] | [.dev,.dst,(.lladdr // "-"),(.state[0] // "UNKNOWN")] | @tsv'ArgumentPasses '.[] | [.dev,.dst,(.lladdr // "-"),(.state[0] // "UNKNOWN")] | @tsv' to jq.
09|PipelinePasses the output on the left to the command on the right.
10sortCommandRuns the sort stage of this one-liner.
This advanced community-curated one-liner combines several stages. Review every option and placeholder before running it.
Example input
ip -j neigh show | jq -r '.[] | [.dev,.dst,(.lladdr // "-"),(.state[0] // "UNKNOWN")] | @tsv' | sort
Example output
eth0 192.168.1.1 00:11:22:33:44:55 REACHABLE
eth0 192.168.1.50 aa:bb:cc:dd:ee:ff STALE
Illustrative output — exact values vary by system and data.
Official sources