Skip to content

PYTHON EDitor: a command to edit lines using Python expressions

Notifications You must be signed in to change notification settings

ebonnal/pythoned

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

unittest pypi

🐉 pythoned

PYTHON EDitor: a command to edit lines using Python expressions

For Pythonistas always forgetting the syntax of sed/awk/grep/tr

install

pip install pythoned

(it sets up pythoned in your PATH)

edit

You provide a Python str expression, manipulating the line stored in the _: str variable:

# get last char of each line
echo -e 'f00\nbar\nf00bar' | pythoned '_[-1]'

output:

0
r
r

filter

If the provided expression is a bool instead of an str, then the lines will be filtered according to it:

# keep only lines whose length equals 3
echo -e 'f00\nbar\nf00bar' | pythoned '"00" in _'

output:

f00
f00bar

modules

Modules are auto-imported, example with re:

# replace digits by Xs
echo -e 'f00\nbar\nf00bar' | pythoned 're.sub(r"\d", "X", _)'

output:

fXX
bar
fXXbar

About

PYTHON EDitor: a command to edit lines using Python expressions

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages