Skip to content

For when you forget the syntax for awk, curl, sed etc. but have the perfect python one-liner for the job.

License

Notifications You must be signed in to change notification settings

ethan-homan/pype

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Pype

Pype lets you run python on data as you pipe it around in your terminal.

Usage

To make a string upper case:

>> echo "python" | pype '_.upper()'
PYTHON

To get the last value in a comma separated list:

>> echo "1,2,3,4,5" | pype '_.split(",")[-1]'
5

Options

If you need to import packages for your one-liner, just pass them using the -m option.

We can use this to make GET requests on a list of URLs using requests, doing something similar to what could be done with curl and jq.

cat links.txt | pype 'requests.get(_).json()["coord"]["lon"]' -m requests

If you want the variable that your input is called to be different than the default _, you can rename it using -n to make your one-liner easier to read.

cat links.txt | pype 'requests.get(link).json()["coord"]["lon"]' -m requests -n link

Installing

git clone https://github.com/ethan-homan/pype.git
cd pype
pip install .

About

For when you forget the syntax for awk, curl, sed etc. but have the perfect python one-liner for the job.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages