grep a large list against a large file

前端 未结 4 853
天命终不由人
天命终不由人 2020-12-07 17:09

I am currently trying to grep a large list of ids (~5000) against an even larger csv file (3.000.000 lines).

I want all the csv lines, that contain an i

4条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-07 17:53

    Try

    grep -f the_ids.txt huge.csv
    

    Additionally, since your patterns seem to be fixed strings, supplying the -F option might speed up grep.

       -F, --fixed-strings
              Interpret PATTERN as a  list  of  fixed  strings,  separated  by
              newlines,  any  of  which is to be matched.  (-F is specified by
              POSIX.)
    

提交回复
热议问题