I have two variables which have values that can be in both. I would like to create a unique list from the two variables.
VAR1="SERVER1 SERVER2 SERVER3"
VAR2="SERVER1 SERVER5"
I am trying to get a result of:
"SERVER1 SERVER2 SERVER3 SERVER5"
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The following pipes a combination of the two lists through the
sortprogram with the unique parameter-u:This gives the output:
Edit:
As William Purcell points out in the comments below, this separates the strings by new-lines. If you wish to separate by white space again you can pipe the output from sort back through
tr '\n' ' ':