How to generate lists of elements from incompatible nhListElements arguments

Document ID : KB000028478
Last Modified Date : 14/02/2018
Show Technical Document Details

In this case we can use the sort/comm commands to provide a list of elements 

which contains only elements which exist in both lists.

1) The comm command compares two sorted lists and has arguments to control
    the output 


comm [options] filea fileb

The option -1 will suppress lines only in filea
The option -2 will suppress lines only in fileb
The option -3 will suppress that appear in both filea and fileb


2) The sort command sorts lines of text files.

So we can use the above commands to provide an intersection of the two lists.


nhListElements -noDbDataFor 1 | sort > sortnodb.txt

nhListElements -inGroup SysGroup | sort > sortsysgroup.txt

comm -12 sortnodb.txt sortsysgroup.txt > intersection.txt

The intersection.txt file will contain a list of elements which
appear in both sortnodb.txt and sortsysgroup.txt.