Quantcast
Channel: Active questions tagged jq - Stack Overflow
Viewing all articles
Browse latest Browse all 657

How to filter list based on prefix list?

$
0
0

I have a list of hostnames and I want to filter out all hostnames that end in any of a given List of domains. For example for the hostnames ["host1.exmaple.org","host2.example.org","example.org","host.example.com","host.example.net"] and the domain List ["example.org","example.net"] the result should be ["host.example.com"]

Filtering against one value works like this map(select( . | endswith("example.com") | not )) but I have not found a sollution for a list of domains.

For those who are interested here is a little bit more context:

All this is part of a shell script.We have a list of domains that are currently registed with the system (${current_domains}), a list of domains that we want to add (${new_domains}) and a list of domains that are currently in a validation process (${requested_domains}).The goal is to get a list of domains that should be inserted added to the validation process but only of none of the "parent" domains are alread added or in the process of being added.


Viewing all articles
Browse latest Browse all 657

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>