perl - Two Lists, compare and show difference plus or minus -


not 100% sure how this. guess each list , make array out of both. can differences how list difference?

list day 1

xxxx-r01 48 xxxx-r02 38 xxxx-r03 28 

list day 2

xxxx-r01 44 xxxx-r02 39 xxxx-r03 29 

desired result.

xxxx-r01 -4 xxxx-r02 1 xxxx-r03 1 

fixed number of columns (differences in second field):

$ awk 'fnr==nr{a[nr]=$2;next}{print $1,$2-a[fnr]}' list1 list2 xxxx-r01 -4 xxxx-r02 1 xxxx-r03 1 

variable number of columns (differences in last field):

$ awk 'fnr==nr{a[nr]=$nf;next}{$nf=$nf-a[fnr]}1' list1 list2 xxxx-r01 -4 xxxx-r02 1 xxxx-r03 1 

Comments

Popular posts from this blog

c# - Operator '==' incompatible with operand types 'Guid' and 'Guid' using DynamicExpression.ParseLambda<T, bool> -