Python Forum
Search string in mutliple .gz files
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Search string in mutliple .gz files
#11
(Aug-25-2021, 08:47 AM)DeaD_EyE Wrote:
(Aug-25-2021, 04:18 AM)ndc85430 Wrote: What's the reason for reimplementing zgrep?

Reimplementing it in Python is better like this:

import subprocess


def zgrep(file, pattern):
    proc = subprocess.Popen(["zgrep", pattern, file], stdout=subprocess.PIPE)
    for line in proc.stdout:
        yield line.decode(errors="replace")
Code, which utilizes zgrep, does not run on Windows.
In addition, it adds a dependency to Python + it's not Python.

The next could be, why to implement cat, sort, awk, sed, ... if we already have them on our machines?
The increase of non-pythonic solutions: https://github.com/arunsivaramanneo/GPU-...wer.py#L24


Output:
Output: python3 ./srch.py path_to_directory matching_text
Yes, what could this mean?
Have you tried python3 ./srch.py --help

It's the normal way how command line tools are controlled. They take options, arguments and parameters.
If you want to list a directory on Linux, you could type: ls -l /

The -l is an option and the / is an argument and points to the target directory which ls should show.


I have tried with python3 still same output - Can you please provide complete code to execute from my end?

$ python3 ./srch.py
python3 ./srch.py path_to_directory matching_text
Reply


Messages In This Thread
Search string in mutliple .gz files - by SARAOOF - Aug-18-2021, 11:07 AM
RE: Search string in mutliple .gz files - by SARAOOF - Aug-26-2021, 01:47 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Writing a Linear Search algorithm - malformed string representation Drone4four 10 924 Jan-10-2024, 08:39 AM
Last Post: gulshan212
  splitting file into multiple files by searching for string AlphaInc 2 877 Jul-01-2023, 10:35 PM
Last Post: Pedroski55
  Search multiple CSV files for a string or strings cubangt 7 7,989 Feb-23-2022, 12:53 AM
Last Post: Pedroski55
  Replace String in multiple text-files [SOLVED] AlphaInc 5 8,087 Aug-08-2021, 04:59 PM
Last Post: Axel_Erfurt
  fuzzywuzzy search string in text file marfer 9 4,546 Aug-03-2021, 02:41 AM
Last Post: deanhystad
  how search files Ron_Crafter 4 46,311 Apr-17-2021, 11:19 AM
Last Post: Ron_Crafter
  I want to search a variable for a string D90 lostbit 3 2,615 Mar-31-2021, 07:14 PM
Last Post: lostbit
  Merging all file_name.log's files from directory to one and search “PerformanceINFO" sutra 0 1,779 Dec-09-2020, 05:14 PM
Last Post: sutra
  String search in different excel Kristenl2784 0 1,700 Jul-20-2020, 02:37 PM
Last Post: Kristenl2784
  Complex word search multiple files Kristenl2784 0 1,577 Jul-18-2020, 01:22 PM
Last Post: Kristenl2784

Forum Jump:

User Panel Messages

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