I want to check the differences between lots of key value pairs. I know I could write some code to do this, but I feel there is going to be an easier way to accomplish this. These values come from HTTP request URLs.
Say I have the following key value pairs, they are not always in order:
Set 1:
a=1
b=2
c=3
Set 2:
a=2
c=5
b=7
Set 3:
b=5
c=2
a=8
Set 4:
a=1
c=6
b=7
I'm looking for an output like this, just so I can easily see differences:
How can I achieve this easily, without having to write my own program?
You could use awk
for this:
cat file1 file2 | awk -F "=" '{i[$1]=(i[$1] " " $2)} END {for (key in i) { print key " " i[key]}}'
Example output:
d 104 42
a 8 9
b 9 13
c 22 -1
Additionally pipe to sort
if you want the values in a consistent order.
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments