The tag has no wiki summary.

learn more… | top users | synonyms

2
votes
1answer
31 views

How does one indent code blocks in `ed`?

I like using ed for small edits. Currently I just press the spacebar manually to indent blocks of code in ed. Is this how the authors of UNIX indented their code in ed? Or is there some shortcut they ...
2
votes
2answers
96 views

Regex `/pattern/g` and ed `:g/pattern/`: which came first, and why `g`?

The g option (e.g. s/pattern/replacement/g) for many tools that use regex-style pattern matching and the :g command in ed/ex/vi/vim have pretty similar usage and meaning: match the given regex ...
0
votes
1answer
36 views

Getting a delimiter issue while executing the script

I am creating a test.sh file and i am running it as ./test.sh: string="hello" ed << EOF e any_file 1i ${string} EOF can anybody help me what it does? I am getting some delimiter issue. Can ...
9
votes
8answers
1k views

How to remove multiple newlines at EOF?

I have files that end in one or more newlines and should end in only one newline. How can I do that with Bash/Unix/GNU tools? Example bad file: 1\n \n 2\n \n \n 3\n \n \n \n Example corrected ...
2
votes
2answers
228 views

Removing consecutive newlines with ed

Input file: 1 line1\ 2 line2\ 3 line3\ 4 \ 5 line4\ 6 \ 7 \ 8 line5\ Desired output: 1 line1 2 line2 3 line3 4 5 line4 6 7 line5 Is it possible with POSIX ed? Removing the trailing backslashes ...
8
votes
2answers
147 views

How to write a literal dot in ed?

What would be the right way to write a line containing only . to a file in ed? The only way I came up with is something like this: a . s/^$/./