سؤال

I have this:

bar foobar        
111 random111

I want to define $2 so that when compared to $1, it should contain only the differences (non-matching characters):

bar foo
111 random
هل كانت مفيدة؟

المحلول

To print the differences as jaypal points out:

awk '{gsub($1,"",$2)}1' file
bar foo
111 random
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top