Python Forum
grep command based on lines in a pattern file
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
grep command based on lines in a pattern file
this is a command i have needed a few times today, so i decided that maybe i should create it.

it is like a grep command, which reads a main file line-by-line (or stdin) and each current line is considered to match if any line of a pattern file is seen as a substring of the current line of the main file. my curiosity is if anyone here would code this (if they were coding this) using the "re" module even when the pattern file does not contain regular expressions. i can envision at least 2 forms of this tool where in one, each line of the pattern file is a regular expression (like in egrep), and in the other, each line of the pattern file is a fixed substring (like in fgrep).

i am not looking for someone else to code this, but if this existed as a complete project before this post, i would like to at least download it to check it out.
Tradition is peer pressure from dead people

What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
Two simple questions
  1. Doesn't 'grep' solve the problem?
  2. Doesn't python's 'grin' solve the problem?

Possibly Related Threads…
Thread Author Replies Views Last Post
  How to Randomly Print a Quote From a Text File When User Types a Command on Main Menu BillKochman 13 1,699 Apr-24-2024, 05:47 AM
Last Post: Bronjer
  Copy Paste excel files based on the first letters of the file name Viento 2 665 Feb-07-2024, 12:24 PM
Last Post: Viento
  Split pdf in pypdf based upon file regex standenman 1 2,406 Feb-03-2023, 12:01 PM
Last Post: SpongeB0B
  Delete multiple lines from txt file Lky 6 2,600 Jul-10-2022, 12:09 PM
Last Post: jefsummers
  failing to print not matched lines from second file tester_V 14 6,638 Apr-05-2022, 11:56 AM
Last Post: codinglearner
  Extracting Specific Lines from text file based on content. jokerfmj 8 3,409 Mar-28-2022, 03:38 PM
Last Post: snippsat
  Facing Problem while opening a file through command prompt vlearner 4 2,188 Jan-30-2022, 08:10 AM
Last Post: snippsat
  Dynamic File Name to a shared folder with open command in python sjcsvatt 9 6,648 Jan-07-2022, 04:55 PM
Last Post: bowlofred
  Rename Files based on XML file klturi421 3 2,395 Oct-22-2021, 07:37 PM
Last Post: klturi421
  use subprocess on linux\pi wwith a "grep " command korenron 2 8,642 Oct-19-2021, 10:52 AM
Last Post: DeaD_EyE

Forum Jump:

User Panel Messages

Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020