Skip to content

go-sed is a simple and efficient command-line tool written in Go for performing basic text transformations, similar to the Unix sed command.

License

Notifications You must be signed in to change notification settings

mk-milly02/go-sed

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

go-sed

go-sed is a simple and efficient command-line tool written in Go for performing basic text transformations, similar to the Unix sed command.

Features

  • Search and replace text in files
  • In-place file editing
  • Addition of double spacing
  • Removal of trailing blank lines
  • Suppress automatic printing of pattern space

Usage

Basic usage of go-sed:

$ go run main.go -h
Usage of: go run main.go [options] [script] [filename]
Options:
    -i string
        edit in-place (default "s/The/Code/g")
    -n string
        only output a range of lines from the file (default "1p")
Script:
    - s/this/that/g
    - G
    - /^$/d
Filename:
    quotes.txt
go run main.go 's/old/new/g' input.txt
  • s/old/new/g: Substitute old with new globally in the file
go run main.go -n '2,4p' input.txt
  • -n '2,4p': Only output a range of lines from the file i.e line 2 to line 4
go run main.go -n /code/p input.txt
  • -n /code/p: Output only lines containing a specific pattern code
go run main.go G input.txt
  • G: Support double spacing a file
go run main.go /^$/d input.txt
  • /^$/d: Strip trailing blank lines from a file
go run main.go -i 's/Life/Code/g' intput.txt
  • -i 's/Life/Code/g': Edit in place

Contributing

Contributions are welcome! Please open an issue or submit a pull request on GitHub.

License

This project is licensed under the MIT License. See the LICENSE file for details.

About

go-sed is a simple and efficient command-line tool written in Go for performing basic text transformations, similar to the Unix sed command.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages