Skip to main content

Cli utility that parses and transforms text

Project description

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.

Installation

$ pip install pysed

uninstall

$ pip uninstall pysed

Command Line Tool Usage

usage: pysed [-h] [-v] [-p] [-s] [-b] [-n]

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
  -s,                   find and replace text
  -b,                   add text before target
  -n,                   add text after the target

Pysed Examples

See changes before save:

$ 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.

$ pysed -s --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.

$ pysed -p example.txt

Python is a widely used general-purpose, high-level programming language.
Its design philosophy emphasizes code readability, and its syntax allows
programmers to express concepts in fewer lines of code than would be possible
in languages such as C. The language provides constructs intended to enable
clear programs on both a small and large scale.


$ pysed -s --print 'high-level' 'HIGH LEVEL' example.txt

Python is a widely used general-purpose, HIGH LEVEL programming language.
Its design philosophy emphasizes code readability, and its syntax allows
programmers to express concepts in fewer lines of code than would be possible
in languages such as C. The language provides constructs intended to enable
clear programs on both a small and large scale.

Replace text:

$ cat example.txt

Python is a widely used general-purpose, high-level programming language.
Its design philosophy emphasizes code readability, and its syntax allows
programmers to express concepts in fewer lines of code than would be possible
in languages such as C. The language provides constructs intended to enable
clear programs on both a small and large scale.



$ pysed -s 'high-level' 'HIGH LEVEL' example.txt
$ cat example.txt

Python is a widely used general-purpose, HIGH LEVEL programming language.
Its design philosophy emphasizes code readability, and its syntax allows
programmers to express concepts in fewer lines of code than would be possible
in languages such as C. The language provides constructs intended to enable
clear programs on both a small and large scale.

Add text after the target:

$ pysed -n 'C' '++' example.txt
$ cat examples.txt

Python is a widely used general-purpose, HIGH LEVEL programming language.
Its design philosophy emphasizes code readability, and its syntax allows
programmers to express concepts in fewer lines of code than would be possible
in languages such as C++. The language provides constructs intended to enable
clear programs on both a small and large scale.

Add text before target:

$ pysed -b 'small' 'big, ' example.txt
$ cat example.txt

Python is a widely used general-purpose, HIGH LEVEL programming language.
Its design philosophy emphasizes code readability, and its syntax allows
programmers to express concepts in fewer lines of code than would be possible
in languages such as C++. The language provides constructs intended to enable
clear programs on both a big, small and large scale.

Replace special character:

$ pysed -s '\+\+' '#' example.txt
$ cat example.txt

Python is a widely used general-purpose, HIGH LEVEL programming language.
Its design philosophy emphasizes code readability, and its syntax allows
programmers to express concepts in fewer lines of code than would be possible
in languages such as C#. The language provides constructs intended to enable
clear programs on both a big, small and large scale.

Remove text:

$ pysed -s 'programming ' '' example.txt
$ cat example.txt

Python is a widely used general-purpose, HIGH LEVEL language.
Its design philosophy emphasizes code readability, and its syntax allows
programmers to express concepts in fewer lines of code than would be possible
in languages such as C#. The language provides constructs intended to enable
clear programs on both a big, small and large scale.

More features come….

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pysed-0.0.1.tar.gz (13.7 kB view details)

Uploaded Source

File details

Details for the file pysed-0.0.1.tar.gz.

File metadata

  • Download URL: pysed-0.0.1.tar.gz
  • Upload date:
  • Size: 13.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for pysed-0.0.1.tar.gz
Algorithm Hash digest
SHA256 ff0666720b991420776cfd192546fbe905c39754bbe6a85b62c3a67ab44782af
MD5 2277c82ebbffd47e5eef90b1487889a2
BLAKE2b-256 b295ec1dd8f38b7a0bd80c5d27934d2d9c6e7ca26d71d5c422209c4a2263c144

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page