0

I have two variables that return:

echo $var1
def abc ghi
echo $var2
abc def abc abc abc

I want the output to return as ghi

3
  • Doesn't look really hard. Have you tried anything on your own (at least something like comm -3 <(echo "${var1// /$'\n'}" | sort -u) <(echo "${var2// /$'\n'}" | sort -u))? Commented May 13, 2021 at 15:30
  • @oguzismail I am new to this, tried couple of things but nothing working, this is working, thanks :) Commented May 13, 2021 at 15:37
  • 1
    Need to show some of the things you've tried. stackoverflow.com/help/how-to-ask Commented May 14, 2021 at 3:56

1 Answer 1

3

as per above comment, this worked for me comm -3 <(echo "${var1// /$'\n'}" | sort -u) <(echo "${var2// /$'\n'}" | sort -u)

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.