Skip to main content
https://badge.fury.io/py/pysed.png https://pypip.in/d/pysed/badge.png https://pypip.in/license/pysed/badge.png

Cli utility that parses and transforms text written in Python.

[CHANGELOG] : https://github.com/dslackw/pysed/blob/master/CHANGELOG

Installation

$ pip install pysed

uninstall

$ pip uninstall pysed

Command Line Tool Usage

usage: pysed [-h] [-v] [-p] [-l] [-e] [-r] [-i]

Utility that parses and transforms text

optional arguments:
  -h, --help     show this help message and exit
  -v, --version  print version and exit
  -p, --print    print text
  -l, --lines    print lines
                 'num' ['>', '<', '*']
  -e, --extract  extract text
                 'text'
  -r, --replace  replace text
                 m max(num)/, u upper/, l lower/ ['^', ',', '*']
  -i, --insert   insert text
                 m max(num)/, u upper/, l lower/ ['^', ',', '*']

Pysed Examples

See changes before modification with options -p –print:

Print text file:

(NOTE: Windows users avoid using quotes ‘’)

$ pysed --print text.txt

This is my cat,
 whose name is Betty.
This is my dog,
 whose name is Frank.
This is my fish,
whose name is George.
This is my goat,
 whose name is Adam.

Print lines:

$ pysed --lines '0,3,2,1,4,7,6,5' text.txt

This is my cat,
 whose name is frank.
This is my dog,
 whose name is betty.
This is my fish,
 whose name is adam.
This is my goat,
whose name is george.

$ pysed --lines '3,7' text.txt

This is my dog,
 whose name is adam.

$ pysed --lines '>' text.txt

This is my cat,

$ pysed --lines '<' text.txt

whose name is adam.

$ pysed --lines '*' text.txt

This is my cat,
 whose name is betty.
This is my dog,
 whose name is frank.
This is my fish,
whose name is george.
This is my goat,
 whose name is adam.

Extract text:

$ pysed pysed --extract 'is' text.txt

is is is is is is is is is is is is is

Remove new lines:

$ pysed -r --print '\n ' ' ' text.txt

This is my cat, whose name is Betty.
This is my dog, whose name is Frank.
This is my fish,
whose name is George.
This is my goat, whose name is Adam.

Redirect results to another file:

$ pysed -r --print '\n ' ' ' text.txt > text2.txt
$ cat text2.txt

This is my cat, whose name is Betty.
This is my dog, whose name is Frank.
This is my fish,
whose name is George.
This is my goat, whose name is Adam.

$ pysed --extract 'This' text.txt > text3.txt
$ pysed -print text3.txt

This This This This

$ pysed --lines '0,2,4,6' text.txt > text4.txt
$ pysed --print text4.txt

This is my cat,
This is my dog,
This is my fish,
This is my goat,

Replace text:

$ pysed -r --print 'This' 'THIS' text.txt

THIS is my cat,
 whose name is Betty.
THIS is my dog,
 whose name is Frank.
THIS is my fish,
whose name is George.
THIS is my goat,
 whose name is Adam.

Replace max:

$ pysed -r --print m2/'This' 'THIS' text.txt

THIS is my cat,
 whose name is Betty.
THIS is my dog,
 whose name is Frank.
This is my fish,
whose name is George.
This is my goat,
 whose name is Adam.

Convert text to uppercase:

$ pysed -r --print u/'This' '^' text.txt

THIS is my cat,
 whose name is Betty.
THIS is my dog,
 whose name is Frank.
THIS is my fish,
whose name is George.
THIS is my goat,
 whose name is Adam.

$ pysed -r --print u/'' '*' text.txt

THIS IS MY CAT,
 WHOSE NAME IS BETTY.
THIS IS MY DOG,
 WHOSE NAME IS FRANK.
THIS IS MY FISH,
WHOSE NAME IS GEORGE.
THIS IS MY GOAT,
 WHOSE NAME IS ADAM.

Convert text to lowercase:

$ pysed -r --print l/'T' ',' text.txt

this is my cat,
 whose name is Betty.
this is my dog,
 whose name is Frank.
this is my fish,
whose name is George.
this is my goat,
 whose name is Adam.

$ pysed -r --print l/'' '*' text.txt

this is my cat,
 whose name is betty.
this is my dog,
 whose name is frank.
this is my fish,
whose name is george.
this is my goat,
 whose name is adam

Insert text:

$ pysed -i --print 'whose ' 'sur' text.txt

This is my cat,
 whose surname is Betty.
This is my dog,
 whose surname is Frank.
This is my fish,
whose surname is George.
This is my goat,
 whose surname is Adam.

Insert max:

$ pysed -i --print m2/'whose ' 'sur' text.txt

This is my cat,
 whose surname is Betty.
This is my dog,
 whose surname is Frank.
This is my fish,
whose name is George.
This is my goat,
 whose name is Adam.

More features come….

Metadata

Release files for pysed 0.1.0

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

Source distribution (sdist)

Source distribution for pysed 0.1.0
File Size Uploaded
pysed-0.1.0.tar.gz 16.3 kB Details

Release files / pysed-0.1.0.tar.gz

Download URL pysed-0.1.0.tar.gz
Size 16.3 kB
Tags Source
SHA-256 checksum
How to use checksums
c6071f6a25c36ca56a44690bb12db5fb6acef00df259d1c0b4db4ca7237483a5
BLAKE2b-256 checksum
How to use checksums
a394003499d32eb67354f9b3c4c8267fc6005ca1ae3514ef1b0bdd0bfa1676fd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

0.7.8

1 release file

0.7.7

1 release file

0.7.6

2 release files

0.7.5

1 release file

0.7.4

1 release file

0.7.3

1 release file

0.7.2

1 release file

0.7.1

1 release file

0.7.0

1 release file

0.6.2

1 release file

0.6.0

1 release file

0.5.2

1 release file

0.5.1

1 release file

0.5.0

1 release file

0.3.1

1 release file

0.3.0

1 release file

0.2.9

1 release file

0.2.8

1 release file

0.2.7

1 release file

0.2.6

1 release file

0.2.5

1 release file

0.2.4

1 release file

0.2.3

1 release file

0.2.2

1 release file

0.2.1

1 release file

0.2.0

1 release file

0.1.9

1 release file

0.1.8

1 release file

0.1.7

1 release file

0.1.6

1 release file

0.1.5

1 release file

0.1.4

1 release file

0.1.3

1 release file

0.1.2

1 release file

0.1.1

1 release file

This release

0.1.0 This release

1 release file

0.0.9

1 release file

0.0.8

1 release file

0.0.7

1 release file

0.0.6

1 release file

0.0.5

1 release file

0.0.4

1 release file

0.0.3

1 release file

0.0.2

1 release file

0.0.1

1 release file

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