I’d use osmconvert and osmfilter - see https://wiki.openstreetmap.org/wiki/Osmfilter .