J
J
juffinhalli2012-05-26 12:50:15
linux
juffinhalli, 2012-05-26 12:50:15

[SOLVED] Comparing two columns

Good afternoon, hackers!

There are 2 text files
. Each file contains an arbitrary number of lines.
Each line contains an arbitrary number.
It is necessary to throw out from both files (or mark with a new character at the beginning) those lines that are contained in another file.

Thanks in advance.

PS Is it possible to solve this problem in LibreOffice or in Microsoft Office?

Answer the question

In order to leave comments, you need to log in

5 answer(s)
E
EvilHedgehog, 2012-05-26
@juffinhalli

The simplest option is if the same lines under different numbers are considered different.

for i in `comm -12 1.txt 2.txt`; do sed -i '' "/^$i\$/d" 1.txt; sed -i '' "/^$i\$/d" 2.txt; done

L
la0, 2012-05-26
@la0

man diff
Try it. sometimes he helps out

I
impass, 2012-05-26
@impass

Unix grep, I think it will help you: There is also a Windows port: gnuwin32.sourceforge.net/packages/grep.htm
-f FILE, --file=FILE
Obtain patterns from FILE, one per line. The empty file contains zero patterns, and therefore matches nothing. (-f is specified by POSIX.)
-v, --invert-match
Invert the sense of matching, to select non-matching lines. (-v is specified by POSIX.)

D
Dmitry, 2012-05-26
@Neir0

Of course you can, using VBA

G
godAlex, 2012-05-27
@godAlex

You can do this if you have MS Access and knowledge of SQL: make a small database (2 tables), copy-paste these columns from a text file there, then write SQL queries:
“SELECT T1.field,T2.field FORM T1,T2 WHERE T1.field= T2.field ”- finding common records, but you can check the boxes using several queries. Open Office also has a database, but I did not use it.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question