Skip to main content

pyil - PYthon InLine

Simple in Python, but hard in BASH? pyil is here to help!

A small utility to use Python expressions in bash scripts

badge

Installation

$ pip3 install pyil-bin

Examples

Print squares

$ echo nums.txt
1
2
3
$ cat nums.txt | pyil "int(i) ** 2"
1
4
9

pyil evaluates the expression using Python, by default once per each line. The line is provided in i variable to the expression evaluation context (without the trailing \n)

Print only even numbers

$ echo nums.txt
1
2
3
$ cat nums.txt | pyil -g "int(i) % 2 == 0"
2

The -g (--grep) option enables line filtering mode - the expression is not printed, but used to determine if the line should be printed

Usage

usage: pyil [-h] [-l | -g | -t | -n] [-i] [-j] E

Shortcut for using Python for line processing

positional arguments:
  E               expression to evaluate

optional arguments:
  -h, --help      show this help message and exit
  -l, --lines     Evaluate expression once, with the `lines` generator
  -g, --grep      Instead of printing the value use it for filtering lines
  -t, --truish    Print only values where bool(val) == True
  -n, --none      Print only values where val != None
  -i, --iterable  Threat resulting value as iterable of separate lines. Usefull with --lines, ignored with --grep
  -j, --json      Print value using json.dump(). Together with --iterable results in NDJSON, ignored with --grep

More examples

TBD

Please report all bugs to GitLab issues

Metadata

Release files for pyil-bin 0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pyil-bin 0.1
File Size Uploaded Provenance
pyil-bin-0.1.tar.gz 3.4 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for pyil-bin 0.1
File Interpreter ABI Platform
pyil_bin-0.1-py3-none-any.whl Python 3 none any Details

Total release size: 7.3 kB

Release files / pyil-bin-0.1.tar.gz

Download URL pyil-bin-0.1.tar.gz
Size 3.4 kB
Tags Source
SHA-256 checksum
How to use checksums
3bb048c098c199deeda0f7e182064349e159289146a32005afd461097fb2baaa
BLAKE2b-256 checksum
How to use checksums
3639f79dd105518ebd974794fe80212e7e625840a83672b96cf5b95b9cc30fac
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.8.13

Release files / pyil_bin-0.1-py3-none-any.whl

Download URL pyil_bin-0.1-py3-none-any.whl
Size 4.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
0582781b23c06bb65251e5a6586e333e1c3ca28e42bacffbfa28e886ba447e81
BLAKE2b-256 checksum
How to use checksums
668a8959af0b6e5be538c96cdcc5d05c9adaa48fa3f9fbc7f088d8470a3c9150
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.8.13

Security for pyil-bin 0.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

Release history Release notifications | RSS feed

This release

0.1 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page