a unix filter for extracting tokens
Project description
Grab — a unix filter for extracting tokens
Grabs specified tokens from lines on stdin.
usage: grab.py [-h] command [projection]
Each character in command specifies a token. grab will scan the input line for each token in command and print them tab-separated.
If projection is specified, only these tokens are printed (0-indexed). Indices are numbers from 0–9.
Installation
$ pip install futils-grab
Examples
- grab first two numbers from each line:
grab dd - grab "-quoted string and number:
grab Qd - grab three numbers, print them in reverse order:
grab ddd 210 - grab client and http status from apache log:
<access.log grab iqd 02
Known token types
- d (integer)
- i (IPv4 address)
- a Address (hostname or IP)
- e (email address)
- q (single-quoted string)
- Q (double-quoted string)
- w (word)
- [ (square-bracketed text)
Override or define new token types
You can define your own token types in ~/.grabrc, as a JSON object that maps token type (single character) to Python Regex.
$ cat ~/.grabrc
{
"b": "foo.?"
}
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file folkol.grab-0.0.5.tar.gz.
File metadata
- Download URL: folkol.grab-0.0.5.tar.gz
- Upload date:
- Size: 4.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/39.1.0 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.7.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
52a76d2f2876cf65b5e31ed4a07a1f080312ea82b2def14f18bf30a9c3d347fa
|
|
| MD5 |
4bdb1e22c2e7878d119c9f447b792f1c
|
|
| BLAKE2b-256 |
cb8de985722ee1a4769aa963fc4656b5147518d7ce78d583757f732aefc10293
|
File details
Details for the file folkol.grab-0.0.5-py3-none-any.whl.
File metadata
- Download URL: folkol.grab-0.0.5-py3-none-any.whl
- Upload date:
- Size: 4.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/39.1.0 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.7.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1a7cc61ea0025137440dfb0d257e36698217b8339568da464d4f8df544773c79
|
|
| MD5 |
0db6fdfebdc6164013b5a132374ccd08
|
|
| BLAKE2b-256 |
ca82dca8881d0e9cf6ba3108e9414884a933f5fb36b7b2d1d9eb1e1150852657
|