I don’t have a Linux box handy, but as a proof of concept, here’s a way to filter by UID/GID I came up with using the “/etc/group” file on my Mac.
preceding texts of firsts ":" of lines whose ((it > 1 AND it < 20) of (following text of lasts ":" of preceding texts of lasts ":" of it as integer)) of file "/etc/group"
This is parsing the lines to extract just the GID (you could do the same with relevance earlier in this thread for UID in the /etc/passwd file). You can plug the range you’re looking for into the (it > 1 AND it < 20) area. It’ll then return lines where the GID is in that range and give you whatever comes before the first colon on those lines.
Found a Linux box, put this together for /etc/passwd:
preceding texts of firsts ":" of lines whose ((it >= 1000 AND it <= 6000) of (preceding texts of first ":" of following texts of firsts "x:" of it as integer)) of file "/etc/passwd"