bash- how to compare only certain lines of text files
Hi. I've got a bunch of text files that have a lot of different information in them, but I want to make sure that certain particular lines have matching information. Even if I could get it to spit out the same lines from each that would be good, but it would be nice to let the machine do the comparison.
For example, I have a line that says FileA path1/xxx_123_Jim_yyy.zzz but in the other file the line is FileA path2/aaa_123_Jim_bbb.zzz This is a good match because the 123_Jim part in both is the same. I have several lines I want to compare, but there are many many lines in these files that are not going to be the same, so diff or comm don't seem to be the things I'm after. Also, the text I am interested in don't necessarily have to be on the same numbered line. Code:
grep-w FileA | awk -F_ ' {print $2,$3} ' Thanks. |
Honestly if you want to avoid creation of temp files and such you should move to using something a bit more robust for this type of operation... perl, ruby, python, etc. It will give you more flexibility.
|
Quote:
Code:
diff <(grep-w FileA | awk -F_ ' {print $2,$3} ') <(grep-w FileB | awk -F_ ' {print $2,$3} ') Cheers, Tink |
All times are GMT -5. The time now is 09:23 AM. |