osmfilter

Filter OpenStreetMap data files by tags and attributes

brewmacoslinux
Try with needOr install directly
Source

About

Command-line tool to filter OpenStreetMap files for specific tags

Commands

osmfilter

Examples

Extract only buildings from an OSM file$ osmfilter input.osm --keep="building=*" -o output.osm
Filter for roads and highways with specific tags$ osmfilter map.osm --keep="highway=primary OR highway=secondary" -o roads.osm
Remove water features and keep everything else$ osmfilter data.osm --drop="natural=water" -o filtered.osm