Deleting lines from one file which are in another file

后端 未结 9 660
余生分开走
余生分开走 2020-11-28 01:46

I have a file f1:

line1
line2
line3
line4
..
..

I want to delete all the lines which are in another file f2:

9条回答
  •  無奈伤痛
    2020-11-28 02:03

    Seems to be a job suitable for the SQLite shell:

    create table file1(line text);
    create index if1 on file1(line ASC);
    create table file2(line text);
    create index if2 on file2(line ASC);
    -- comment: if you have | in your files then specify “ .separator ××any_improbable_string×× ”
    .import 'file1.txt' file1
    .import 'file2.txt' file2
    .output result.txt
    select * from file2 where line not in (select line from file1);
    .q
    

提交回复
热议问题