I have a variable that contains short hostname, FQDN and IP addresses.
I need to filter sort hostname/FQDNs and it should store to a variable and also IP addresses should store to an another variable(this am able to do using ipaddr)
Please help me to filter hostnames and store to a variable.
You didn't quote the newline.
But, you don't really need that as the default is to split by white space.
For the literal IPv4 address it's indeed easy, as you can just use the
ipaddr filter.
For the hostname you can use the select() test, in combination with
some regular expression that needs to match.
Depending on how formal/exact you want to define "a hostname", the
regex can simple or really complex.
A simple example: