Artificial intelligent assistant

How to find the difference in tokens in two strings using Unix tools? I have two strings as below- token1, token2, token3, token4, token5, token6, token8, token9, token10 token2, token7, token4, token3, token5, token6, token8, token10, token9 Visually, I can see that "tokens" like `token1` and `token7` are not present in both strings. But is there an easy way to get the differing tokens using Unix tools? The long route would be to write a script and maintain a hashmap of {token => count} and in the end print only those keys that have count = 1. But I suppose there is a shorter way.

GNUly:


s1='token1, token2, token3, token4, token5, token6, token8, token9, token10'
s2='token2, token7, token4, token3, token5, token6, token8, token10, token9'
comm <(grep -oE '\w+' <<< "$s1" | sort) <(grep -oE '\w+' <<< "$s2" | sort)


Gives:


token1
token10
token2
token3
token4
token5
token6
token7
token8
token9


The columns are:

1. tokens only in s1
2. tokens only in s2
3. tokens in both.



You suppress a column by passing the corresponding option (like `-3` to suppress the 3rd column).

xcX3v84RxoQ-4GxG32940ukFUIEgYdPy fb80132203cbb193de9dd21c64c3b4a3