Questions tagged [ed]

ed is a line-oriented text editor for Unix. Use this tag for questions related to ed scripting; questions about interactive usage are considered off-topic.

ed was created in 1969 by Ken Thompson as a simplified successor to the QED editor and was part of the first version of Unix. It is still part of the POSIX standard.

Unlike visual ("full-screen") editors such as vi/vim, ed is a line editor. It pioneered and influenced many features seen in popular tools such as grep, sed, ex, and vi/vim.

ed commands can be stored in scripts; notably, the diff tool can be set to generate ed commands when using the -e command line option.

Questions about scripting with ed are likely to be suitable for Stack Overflow; questions about interactive usage might be better suited for Unix & Linux or Super User.

References

66 questions
1
vote
1 answer

Linux ed Editor multiple search/replaces in one line

I want to do multiple replaces in one line with the ed editor in Linux in the following file: #device device mount FS fsck mount mount #to mount to fsck point type pass at boot options # #/dev/dsk/c0d0s2…
1
vote
1 answer

Non-greedy regex matching in ed (editor)

I am looking at a line of a file I opened with ed and displayed with .p: First sentence. Another. One. Text continues Now I want to replace the string First sentence. with replacement. However, the command .s/.*\./replacement./ acts in a greedy…
1
vote
1 answer

Fastest way to delete a sentence in ed

By a sentence in a text I mean a string that may span several lines; its beginning is the beginning of a line, or a period (.) followed by a space, and it is ended by a period followed by at least one space or newline. What is a good way in ed to…
1
vote
1 answer

select noncontinuous lines in Ed

if 3,5p prints lines 3, 4, and 5, how would one print, say, lines 4 AND 7, but not 5 and 6? Have tried: 3 5 p prints line 8 3p5p breaks as well
jellies
  • 639
  • 1
  • 5
  • 17
1
vote
1 answer

How to do a case insensitive search in ed line editor

I am trying to do a regex search with ed. e.g. Is there an expression that will match any case variation on the word "prop" prop, PROP, Prop, etc. ? I found the following additional references ed manual which refers to Base Definitions volume of…
RaamEE
  • 3,017
  • 4
  • 33
  • 53
1
vote
1 answer

ed - quoting control characters?

How can I search for control characters in unix ed(1)? For example ed somefile.log <
Rumbleweed
  • 370
  • 1
  • 9
1
vote
3 answers

change random line with shellscript

how can i easily (quick and dirty) change, say 10, random lines of a file with a simple shellscript? i though about abusing ed and generating random commands and line ranges, but i'd like to know if there was a better way
knittl
  • 246,190
  • 53
  • 318
  • 364
1
vote
1 answer

How do I remove console output from an ed command?

I'm using ed to insert contents in a file at a particular line number. This is the code section of my ed command. ed servertest << END $LineNumber #15i $Text #this is text . w q END The above code works fine and prints the text onto…
carol Alex
  • 353
  • 1
  • 3
  • 15
1
vote
1 answer

How Insert 2 variable into ed command argument?

I'm trying to do a while loop into bash script but I don't know what's going on with the ed (text editor) when I tried to insert a varible in its arguments. As you can see, I'm using a loop as well, but the problem seem to be in the use of varibles…
git
  • 151
  • 9
1
vote
2 answers

here-document delete first line from file with vim like ed

I am using this snippet code (just delete first line with ed). I wanna know if i can make something like this in vim. I wrote the script and passed the file as an argument. file: # This is a comment # foo bar edit with ed: ed $1 << EOF 1/^[…
Roman Kiselenko
  • 43,210
  • 9
  • 91
  • 103
1
vote
1 answer

expand shell variable in ed onliner

I want to shorten a log file on a unix system with very limited shell capability. My preferred way to do this would be with ed. Deleting a fix number of lines works fine: ed -s file.txt <<< $'1,4d\nwq' But how can I expand the number of lines to…
StackUnderflow
  • 159
  • 1
  • 7
1
vote
1 answer

ed - line editor (what does $p do?)

I am using ed a unix line editor and the book i'm reading says to type 1,$p (also works in vim) after trial and error I figured the first value means the line number but whats the purpose to $p? from what i can tell is the 1 goes to the beginning…
Exploit
  • 6,278
  • 19
  • 70
  • 103
1
vote
3 answers

using Linux shell script to edit and rename a file

I am trying to execute a command using Vi or ex to edit a file by deleting the first five lines, replace x with y, remove extra spaces at the end of each line but retain the carraige returns, and remove the last eight lines of the file, then rename…
camarokris
  • 345
  • 1
  • 3
  • 9
0
votes
2 answers

Replace strings with text with GNU ed

I want to replace %foo% (found in file test) with a string containing every possible character. Because of the missing character limitation, the following is not possible (executed in BASHv4): echo %foo% > test replacement="//this//is//a//test" ed…
Rayne
  • 2,620
  • 20
  • 28
0
votes
0 answers

How to run the ed editor from a Windows terminal?

I followed all the correct steps and I'm still getting a "Invalid argument" error. Here the steps: Manually install ed from here: https://gnuwin32.sourceforge.net/packages/ed.htm. Setup file is the ones that says "Complete package, except…
Miriam
  • 1
  • 1