All Projects → ncornette → greptile

ncornette / greptile

Licence: LGPL-3.0 license
Fast grep implementation in python, with recursive search and replace

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to greptile

Grab
experimental and very fast implementation of a grep
Stars: ✭ 230 (+1252.94%)
Mutual labels:  fast, regex, grep
DFIRRegex
A repo to centralize some of the regular expressions I've found useful over the course of my DFIR career.
Stars: ✭ 33 (+94.12%)
Mutual labels:  regex, grep
splinter
Simple pattern-based linter 🐀
Stars: ✭ 31 (+82.35%)
Mutual labels:  regex, grep
Sakura
SAKURA Editor (Japanese text editor for MS Windows)
Stars: ✭ 689 (+3952.94%)
Mutual labels:  regex, grep
Grepbugs
A regex based source code scanner.
Stars: ✭ 118 (+594.12%)
Mutual labels:  regex, grep
Ripgrep
ripgrep recursively searches directories for a regex pattern while respecting your gitignore
Stars: ✭ 28,564 (+167923.53%)
Mutual labels:  regex, grep
Ugrep
🔍NEW ugrep v3.1: ultra fast grep with interactive query UI and fuzzy search: search file systems, source code, text, binary files, archives (cpio/tar/pax/zip), compressed files (gz/Z/bz2/lzma/xz/lz4), documents and more. A faster, user-friendly and compatible grep replacement.
Stars: ✭ 626 (+3582.35%)
Mutual labels:  regex, grep
Rare
Fast, realtime regex-extraction, and aggregation into common formats such as histograms, numerical summaries, tables, and more!
Stars: ✭ 76 (+347.06%)
Mutual labels:  regex, grep
Command Line Text Processing
⚡ From finding text to search and replace, from sorting to beautifying text and more 🎨
Stars: ✭ 9,771 (+57376.47%)
Mutual labels:  regex, grep
Learn gnugrep ripgrep
Example based guide to mastering GNU grep and ripgrep
Stars: ✭ 204 (+1100%)
Mutual labels:  regex, grep
core
🌈 light, fast, and easy to use, dependencies free javascript syntax highlighter, with automatic language detection
Stars: ✭ 40 (+135.29%)
Mutual labels:  fast, regex
ios-application
A native, lightweight and secure one-time-password (OTP) client built for iOS; Raivo OTP!
Stars: ✭ 581 (+3317.65%)
Mutual labels:  fast
discrete-math-python-scripts
Python code snippets from Discrete Mathematics for Computer Science specialization at Coursera
Stars: ✭ 98 (+476.47%)
Mutual labels:  recursive
antk
Redkato, - Indonesian anime scraper
Stars: ✭ 14 (-17.65%)
Mutual labels:  regex
STYLER
Official repository of STYLER: Style Factor Modeling with Rapidity and Robustness via Speech Decomposition for Expressive and Controllable Neural Text to Speech, INTERSPEECH 2021
Stars: ✭ 105 (+517.65%)
Mutual labels:  fast
ast-grep
🔍 Like grep, but more powerful than you can possibly imagine
Stars: ✭ 14 (-17.65%)
Mutual labels:  grep
replace
Generic file search & replace tool, written in Python 3
Stars: ✭ 28 (+64.71%)
Mutual labels:  regex
js-diacritic-regex
Creates the inverse of transliterated string to a regex. What? Basically, diacritic insensitiveness
Stars: ✭ 20 (+17.65%)
Mutual labels:  regex
ngp
Ncurses code parsing tool
Stars: ✭ 52 (+205.88%)
Mutual labels:  grep
cstruct-go
a fast c-style struct packer & unpacker for golang
Stars: ✭ 28 (+64.71%)
Mutual labels:  fast

Build Status Codacy Badge codecov PyPI

Greptile

Fast grep implementation in python, with replace features

usage: greptile.py [-h] [-v] [-x EXTENSIONS [EXTENSIONS ...]] [-r] [-l] [-i]
                   [-g REPLACE_EXPR] [-f REPLACE_EXPR]
                   expression [file]

file search and replace with regular expressions

positional arguments:
  expression            regular expression
  file                  file path (or directory if -r is used)

optional arguments:
  -h, --help            show this help message and exit
  -v, --version         show program's version number and exit
  -x EXTENSIONS [EXTENSIONS ...], --extensions EXTENSIONS [EXTENSIONS ...]
                        restrict search to file extensions (ex: .py .txt .java
                        .xml)
  -r, --recursive       recursively search in path
  -l, --list            list files matching pattern
  -i, --inplace         update the file inplace (with -g or -f)
  -g REPLACE_EXPR, --replace-global REPLACE_EXPR
                        global replacement expression
  -f REPLACE_EXPR, --replace-first REPLACE_EXPR
                        first occurrence replacement expression

Why fast?

Because it exclusively uses generators, reptile never allocates big lists, it always processes one line in one file at a time. you can do a search on big files and large directories like / recursively without memory overhead.

Examples:

Search "import" in ./greptile.py :

$ ./greptile.py "import" ./greptile.py
import re
import os
import sys
    import argparse

Recursively search from ~/ lines in python files containing Copyright :

$ ./greptile.py -x .py -r "Copyright" ~/
/Users/nic/Library/Android/sdk/platform-tools/systrace/systrace-legacy.py 2:  # Copyright (c) 2011 The Chromium Authors. All rights reserved.
/Users/nic/Library/Android/sdk/platform-tools/systrace/systrace.py 2:  # Copyright (c) 2011 The Chromium Authors. All rights reserved.
/Users/nic/Library/Android/sdk/platform-tools/systrace/systrace_agent.py 0:  # Copyright (c) 2015 The Chromium Authors. All rights reserved.
/Users/nic/Library/Android/sdk/platform-tools/systrace/util.py 0:  # Copyright (c) 2015 The Chromium Authors. All rights reserved.
/Users/nic/Library/Android/sdk/platform-tools/systrace/agents/__init__.py 0:  # Copyright (c) 2015 The Chromium Authors. All rights reserved.
/Users/nic/Library/Android/sdk/platform-tools/systrace/agents/atrace_agent.py 0:  # Copyright (c) 2015 The Chromium Authors. All rights reserved.
...

Replacement & easy grouping with python re.sub syntax :

$ greptile.py "\[(.*)\]\((.*)\)" README.md -g "<a href=\"\2\">\1</a>" | diff -u README.md -
--- README.md	2016-04-19 22:37:20.000000000 +0200
+++ -	2016-04-25 14:54:24.000000000 +0200
@@ -1,4 +1,4 @@
-![Agera](https://github.com/google/agera/blob/master/doc/images/agera.png)
+!<a href="https://github.com/google/agera/blob/master/doc/images/agera.png">Agera</a>
 Reactive Programming for Android
 ================================

Api:

import greptile

# Replace "import" by "export" from dir `./`, in all files and these extensions: .py, .xml, .java
greptile.replace('import', 'export', './', '.py', '.xml', '.java')

# Return filenames of all files containing the text "import" from dir `./` and .py, .xml, .java
my_list = greptile.grep_rl('import', './', '.py', '.xml', '.java')

# same as calling replace()
greptile.sed_i(my_list, 'import', 'export')
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].