Greetings everyone,
First of all I am a first time poster, so "hello", second of all I have a problem, I have been scratching my head and "Googling" for quite some time but still can't find an adequate or reasonably simple solution for my problem.
I have a file and it is delimited by tabs as seen below tabs:
## Short segmentation
Code:
AddTimers icq.c root/modules/icq -> KeepAlive icq.c root/modules/icq
AddTimers icq.c root/modules/icq -> SelectServer icq.c root/modules/icq
AddTimers icq.c root/modules/icq -> eb_timeout_add plugin_api.c root/src
Connect_Remote send.c root/modules/icq/libicq -> ICQ_Debug libicq.c root/modules/icq/libicq
Connect_Remote send.c root/modules/icq/libicq -> proxy_connect libproxy.h root/libproxy
Connect_Remote send.c root/modules/icq/libicq -> proxy_gethostbyname libproxy.h root/libproxy
Connect_Remote send.c root/modules/icq/libicq -> set_nonblock tcp.c root/modules/icq/libicq
Connect_Remote send.c root/modules/icq/libicq -> strdup yahoo_util.h root/modules/yahoo2/libyahoo2
ayttm-0.2.2 Connect_Remote send.h root/modules/icq/libicq -> ICQ_Debug libicq.c root/modules/icq/libicq
If you're asking yourself what the devil that is, it's just a break down of an early version of ayttm, but I digress, this is what I want to do. I wish to match the three strings e.g. (AddTimers icq.c root/modules/icq) on the left hand side of the -> against the three strings on the right hand side of the -> and if they match, remove the entire line.
There are numerous ways I have attempted this, however, due to my lack of competence in bash scripting and regular expressions (I am working on it) both of which have contributed towards my demise. I am not asking for an answer, I will never learn that way, but just a simple push in the right direction.
Thank you for reading.
Thomas Knowles.
edit.
Code:
grep -Ev '^(.+)\s*->\s*\1$' file
submitted by radoulov
Example use
Code:
AddTimers icq.c root/modules/icq -> KeepAlive icq.c root/modules/icq
AddTimers icq.c root/modules/icq -> SelectServer icq.c root/modules/icq
AddTimers icq.c root/modules/icq -> eb_timeout_add plugin_api.c root/src
Connect_Remote send.c root/modules/icq/libicq -> ICQ_Debug libicq.c root/modules/icq/libicq
Connect_Remote send.c root/modules/icq/libicq -> proxy_connect libproxy.h root/libproxy
yyparse plural.c root/intl -> new_exp_1 plural.c root/intl
yyparse plural.c root/intl -> new_exp_2 plural.c root/intl
yyparse plural.c root/intl -> new_exp_3 plural.c root/intl
yyparse plural.c root/intl -> yyparse plural.c root/intl
AddTimers icq.c root/modules/icq -> AddTimers icq.c root/modules/icq
Returned values when applying the grep.
Code:
AddTimers icq.c root/modules/icq -> KeepAlive icq.c root/modules/icq
AddTimers icq.c root/modules/icq -> SelectServer icq.c root/modules/icq
AddTimers icq.c root/modules/icq -> eb_timeout_add plugin_api.c root/src
Connect_Remote send.c root/modules/icq/libicq -> ICQ_Debug libicq.c root/modules/icq/libicq
Connect_Remote send.c root/modules/icq/libicq -> proxy_connect libproxy.h root/libproxy
yyparse plural.c root/intl -> new_exp_1 plural.c root/intl
yyparse plural.c root/intl -> new_exp_2 plural.c root/intl
yyparse plural.c root/intl -> new_exp_3 plural.c root/intl