Priya Jain
Priya Jain

Reputation: 33

Diff of two variables in bash

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

Upvotes: 0

Views: 511

Answers (1)

Priya Jain
Priya Jain

Reputation: 33

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

Upvotes: 3

Related Questions