https://github.com/raypereda/ledit
ledit is a line editor to transform lines in text files.
https://github.com/raypereda/ledit
command-line-tool golang regular-expressions sed simple text-processing
Last synced: 7 months ago
JSON representation
ledit is a line editor to transform lines in text files.
- Host: GitHub
- URL: https://github.com/raypereda/ledit
- Owner: raypereda
- Created: 2017-09-11T01:17:48.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2017-11-04T00:10:26.000Z (almost 8 years ago)
- Last Synced: 2025-01-14T15:17:40.274Z (9 months ago)
- Topics: command-line-tool, golang, regular-expressions, sed, simple, text-processing
- Language: Go
- Homepage:
- Size: 3.43 MB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.txt
Awesome Lists containing this project
README
From the command-line help:
$ ledit -h
ledit is a line editor to transform lines in text files.
Matches of the pattern pat are replaced with the replacement string repl.
The syntax of the regular expression is here: https://github.com/google/re2/wiki/Syntax
Inside repl, $ signs are interpreted as in the link below.
https://golang.org/pkg/regexp/#Regexp.Expand
For instance $1 represents the text of the first submatch.
The output file has an ".ledit" appended to the end.-debug
prints debug info to standard error
-input string
the glob pattern of input text files. Empty string uses stdin and stdout.
-pat string
the regular expresion searched within each line
-repl string
replace text for pattern matched
-------------------
Examples:Example #1
$ ledit -debug -pat=dog -repl=cat -input=input1.txt
Debug for ledit
glob pattern of input files: "input1.txt"
regular expression pattern : "dog"
replacement expression : "cat"
editing file: input1.txt
line: 2
matched : Let's go walk the dog at night.
replaced with: Let's go walk the cat at night.Example #2
$ ledit -debug -pat="false" -repl="true" -input=input2.html
Debug for ledit
glob pattern of input files: "input2.html"
regular expression pattern : "false"
replacement expression : "true"
editing file: input2.html
line: 4
matched : false
replaced with: trueExample #3
$ ledit -debug -pat=10.0.0.2 -repl=10.0.0.99 -input=input3.toml
Debug for ledit
glob pattern of input files: "input3.toml"
regular expression pattern : "10.0.0.2"
replacement expression : "10.0.0.99"
editing file: input3.toml
line: 4
matched : ip = "10.0.0.2"
replaced with: ip = "10.0.0.99"The OSX executable is cmd/ledit/ledit.
The Windows 64-bit executable is cmd/ledit/ledit.exe.sed is a stream editor that is a bit old and cryptic.
You can problem solve your problem with a line editing using sed.
I prefer something easy to use and easy to modify source code.