How to merge two slists and remove duplicate entries? #4473
-
|
I have two slists: And would like to merge those two together but remove the duplicate entry: "one". I see the So far I have Which gives me: But I can't figure out how to do the merged and unique steps in one statement so as to avoid creating yet another variable in between. I tried this: But that gives me a bunch of parser errors. I suppose that mergedata doesn't parse an "inline" list? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 6 replies
-
|
Using the return value of (I like to not quote string args like Output: More information in the docs: |
Beta Was this translation helpful? Give feedback.
-
|
As a follow-up, I also needed to merge in a scalar. With a bit of experimentation I found a way that seems to work! :O Although it requires an awful lot of "special character wrapping" around the scalar ;) |
Beta Was this translation helpful? Give feedback.
Using the return value of
mergedata()directly, as an argument tounique()works:(I like to not quote string args like
list1andlist2, to hint that they are variables, and not just string values. To CFEngine it doesn't really matter).Output:
More information in the docs:
unique()mergedata()