0

i generated a big text file input.txt, the content is lines of file paths, which i will use later in a loop but there're some path patterns i want to remove, like node_modules

i have the ignore patterns saved in ignore.txt file, how can i filter a input.txt file according to ignore.txt file to generate output.txt file, with all path patterns removed?

thank you!

2
  • See mywiki.wooledge.org/BashFAQ/036 which might be what you wanted, but that question is also a FAQ in here so there might be some answers laying around this site. Commented Mar 8, 2021 at 5:33
  • How did you generate your file? It seems as if the file is unimportant if you can generate the list and ignore those directories while doing so. Somewhat like what's happening here: unix.stackexchange.com/questions/638960 Commented Mar 13, 2021 at 22:07

1 Answer 1

1

i guess my question was too vague, i googled around and found it can be done like this:

grep -vf ignore.txt input.txt > output.txt 

ignore.txt:

test/ tests/ _test. /node_modules/ 

input.txt was generated by find, every line is a file path, it's very large

output.txt is in same format/content as input.txt, with paths in ignore.txt patterns removed

1
  • 1
    Note that your pattern _test. would also filter out lines containing _test_ (and _test/, and _test- etc.), so the pattern _test_ is not needed. Commented Mar 14, 2021 at 11:55

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.