Is there a unix command to retrieve NS records from domain?
$ dig example.com NS
works just fine for me. No, it doesn't resolve the IP addresses of the nameservers, but that's not part of the NS record. You'll have to do that yourself. Unlike the output of whois, it's in a standardized format, so it'll be easier to parse.
nslookup -query=ns <server.com>