https://github.com/mk-milly02/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.
https://github.com/mk-milly02/go-sed
filesystem golang sed unix
Last synced: 14 days ago
JSON representation
go-sed is a simple and efficient command-line tool written in Go for performing basic text transformations, similar to the Unix sed command.
- Host: GitHub
- URL: https://github.com/mk-milly02/go-sed
- Owner: mk-milly02
- License: mit
- Created: 2025-01-07T08:26:41.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-01-07T08:38:22.000Z (over 1 year ago)
- Last Synced: 2025-02-28T09:53:38.776Z (over 1 year ago)
- Topics: filesystem, golang, sed, unix
- Language: Go
- Homepage: https://codingchallenges.fyi/challenges/challenge-sed
- Size: 6.84 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# 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`:
```sh
$ 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
```
```sh
go run main.go 's/old/new/g' input.txt
```
- `s/old/new/g`: Substitute `old` with `new` globally in the file
```sh
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
```sh
go run main.go -n /code/p input.txt
```
- `-n /code/p`: Output only lines containing a specific pattern `code`
```sh
go run main.go G input.txt
```
- `G`: Support double spacing a file
```sh
go run main.go /^$/d input.txt
```
- `/^$/d`: Strip trailing blank lines from a file
```sh
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](LICENSE) file for details.