Sample Header Ad - 728x90

Compare two files and generate another on matching condition

-1 votes
4 answers
119 views
I have two files, a.txt and b.txt, where a.txt contains lines starting with "zn", e.g., zn12c5b or  zn4i8l, while b.txt contains lines ending with a pattern "/number", e.g., t17v11/112 or 12c5b/450. My aim is to write in final.txt the strings in a.txt (but without "zn") which do not match with strings in b.txt (without the trailing "/number" pattern). For example: a.txt : zn12c5b zn4i8l b.txt: t17v11/112 12c5b/450 4i8ls/681 I should obtain the following output in final.txt: 4i8l note: 4i8l in file a.txt (without the "zn" prefix) does not equal 4i8ls from file (without the "/681" suffix). I am using an Ubuntu system.
Asked by lina32 (47 rep)
Jul 11, 2020, 03:40 AM
Last activity: Jul 13, 2020, 06:18 PM