The line editor ed in UNIX/Linux has a "command mode" and an "insert mode" and there is no visual way to tell which mode you are in. However, there is a -p option that causes it to display a prompt when you are in command mode, which is very helpful.

Why is the default to have no prompt? Masochism?

  • 17
    All of classic Unix is extremely terse. Notice also that most commands like cp or rm return no message upon completion, unless there's an error. The first terminals were usually printing teletypes running at an excruciating 110 baud. Every character printed meant time, paper, ink and mechanical wear. So extreme frugality was the practice.
    – RETRAC
    Commented Dec 7, 2019 at 17:51
  • 2
    Please write answers in the answer section Commented Dec 8, 2019 at 19:50
  • 6
    @LightnessRaceswithMonica I commented because sadly, it's not really an answer. Just some background context. I don't know why ed doesn't even have a prompt, given that e.g. the shell does. Just wanted to point out that terseness is a tendency in Unix systems.
    – RETRAC
    Commented Dec 9, 2019 at 17:46
  • When you use ed in scripts (for example to merge two files, note diff has a mode that outputs ed scripts) a prompt would really be a nuisance.
    – tofro
    Commented Nov 12, 2022 at 13:43

8 Answers 8


Just when you think this question has been put to bed It raises its head yet again with greater authority. This time, from the horses mouth - so to speak - Bill Joy himself. It is an interview with the UNIX Review in the web masoleum called archive.org:

Excerpt from an interview of Bill Joy of Sun Microsystems by Jim Joyce of UNIX Review. Entitled: Interview with Bill Joy the text appeared in the August 1984 issue of Unix Review magazine.

https://web.archive.org/web/20120210184000/http://web.cecs.pdx.edu/~kirkenda/joy84.html. Bill is being asked about how things evolved around him and here they have arrived at the subject of usability in the context of limited hardware capability at that time. They start out by joking that 'cat' is the most efficient editor for the job at that time ... ...

REVIEW: Real programmers use cat as their editor. JOY: That's right! There you go! It is too much trouble to say ed, because cat's smaller and only needs two pages of memory - plus you're not likely to get swapped out. That's why ed didn't prompt, you know. The performance of the system was just horrible. It would swap things out randomly and do all sorts of things. In ed you might type "a", but have no idea how far behind the system was. And it didn't matter, and long as it didn't get more that a few hundred characters behind and start throwing lines away without telling you.

Typically it wasn't that bad. If it had been prompting, you would have hit carriage return and wait for the prompt, and it would have taken three seconds to comment. That's something we noticed when we put em up. We put in the prompt and suddenly realized it had to go through the operating system.

I think UNIX has lived with grace for years. We've had the grace of people not being able to tell when the system was doing a bad job of scheduling the CPU. Now we can't hide behind time-sharing.


There's plenty more before this point in the article but it would be off-topic. So they had noticed that a prompt which was in the 'em' editor they were also working on, was vulnerable to UNIX swapper stack trashing and the prompt response queue was also too narrow to timeously notify the user ...

So they did not implement an 'ed' prompt on account of performance under UNIX multi-user time share loads, and also over hardware limitations of that era.

  • 1
    It might have been helpful if ASCII had included flow-control characters to operate a four-way "ready" indicator which would indicate ready to receive an arbitrary amount of input, ready to receive a line, ready to receive a character, or not ready to receive any. A mechanically-encoded keyboard like the ASR-33 could have provided tactile feedback to the operator when an intended keystroke wouldn't be able to register, while electronic keyboards could use a light to indicate readiness and a beep to indicate rejected keystrokes.
    – supercat
    Commented Jan 9, 2023 at 22:54
  • 3
    @supercat - tactile feedback from an ASR-33? Those things were nothing BUT tactile feedback! Your hands shook, your fingers were numb from pressing so hard, your feet shook through the floor - if they had any more tactile feedback your fingers would fly right off your hands! (And the noise ...)
    – davidbak
    Commented Jan 9, 2023 at 23:05
  • 1
    good find, that interview!
    – davidbak
    Commented Jan 9, 2023 at 23:06
  • 1
    @davidbak: From what I recall, if one tried to type two characters more than 1/10 second apart, the ASR-33 wouldn't let the second key descend until the mechanism had finished cycling after the first character. Also, if I recall, keypunches and mechanical typewriters could be configured with margins, and lock the keyboard--in a manner that could be clearly felt--if someone typed too much.
    – supercat
    Commented Jan 9, 2023 at 23:19

Having used ed years ago on printing terminals (such as teletypes and DECwriters), I think the reason for having no prompt was that on pressing RETURN after one command, you didn't have to wait for a prompt to be printed before starting to type the next command.

Similar considerations made it better for ed to have ? as the only error message: you would have worked out what the mistake was long before a longer error message had finished printing.

  • 7
    Actually, ed had a second error message: it printed ?tmp if its temporary file was full. Commented Dec 6, 2019 at 12:36
  • Right... and those error messages go to stderr.
    – O. Jones
    Commented Dec 7, 2019 at 21:10
  • @O.Jones: Not in the Sixth Edition. Commented Dec 7, 2019 at 22:40
  • 1
    On a system which echos characters when they are read, the delay wouldn't be an issue, but you raise a good point about systems which echo them as they are typed--an approach which may be good from a CPU usage perspective, but is bad as a UI.
    – supercat
    Commented Dec 18, 2019 at 23:24
  • 7
    I think you misunderestimate the psychological effect of trying to type on machines that noisy while holding the changes you'd planned in your head! Commented Dec 19, 2019 at 20:01

When I was a lad, the only reason ed was included at all in our environment is because it was used by the standard system scripts.

Originally, having to clean the 'prompts' out of ed output to clean up the data would have just made everything more difficult -- much more difficult.

Later, having ed default to something different would have just broken all the existing scripts.

  • 2
    Welcome to RC.SE, necromancer2! :-)
    – cjs
    Commented Dec 6, 2019 at 4:06
  • 1
    Sounds like your beard have hardly greyed yet... Commented Dec 21, 2019 at 15:57
  • Fair point. Some of us learned ed in '01 just so we could write scripts that edit text files. I decided I'd rather script vi. Man that gave the grader a headache.
    – Joshua
    Commented Jun 15, 2020 at 16:25
  • @Joshua In '01, which system did not have sed? Commented Nov 18, 2022 at 0:10
  • @rackandboneman: Learned on HP-UX with a sed that didn't have a write back to input file in the manual (big fat book). It may well have been there, but it wasn't in the manual.
    – Joshua
    Commented Nov 18, 2022 at 1:23

However, there is a -p option that causes it to display a prompt when you are in command mode

The -p option is meant to set a different prompt. When used, a side-effect is that ed starts in addition with prompt enabled.

Why is the default to have no prompt?

There is a default, * (asterisk); it's just not switched on. Prompt display can be toggled by applying a P command (*1).

Ed is meant as well for automated (scripted) use (*2). Having the prompt displayed for each command entered is at least annoying; on a real TTY it will waste a lot of paper.

To display no prompt by default seems sensible in an early environment, doesn't it?

In addition, it might be good to keep in mind that programming back then, especially when done online, was handled mostly in the head, not on a screen or alike. When using ed, one had to have a proper image present. Printing the whole file or just parts thereof would eat up a lot of paper and even more important time. Listing just a page would easily take a minute or two.

With that background it's rather trivial to keep aware what mode one is in. After all, it's not complicated, as default is command and input is only activated on request.

*1 - The prompt is a rather new addition as Stephen Kitt mentioned.

*2 - I always loved the feature to 'open' any shell command as an input 'file'.

In fact, ed even predates next to all other Unix tools as well as basic output direction itself (which was a shell feature until pipes were added in V3 (?)). So the standard way to capture a program output was to 'open' it as ed input file and save it as text file:

$ ed
r !ls -l
w directory_listing
  • 5
    “To display no prompt by default seams sensible in an early environment” — indeed, although it might not be obvious why nowadays ;-). Incidentally, older versions of ed don’t support prompts at all, they’re a somewhat recent addition. Commented Dec 5, 2019 at 20:15
  • @StephenKitt was it? I never thought about - in fact, I never used P at all, just looked it up a few minutes ago. Do you know when it was added?
    – Raffzahn
    Commented Dec 5, 2019 at 20:28
  • 4
    I’m not sure when it was added; even the V10 manpage doesn’t mention it, I think it came from BSD — 3BSD has it. So “somewhat recent” for some values of recent, around 40 years ago ;-). Commented Dec 5, 2019 at 22:30
  • 4
    Browsing through minnie.tuhs.org, in V6 (1975), 'P' is an error. In V7 (1979) 'P' was a synonym for 'p'. In Sys III (1982), 'P' toggled the prompt. Commented Dec 5, 2019 at 22:48
  • 1
    @KelvinSherlock Thanks. :) I guess we all have forgotten how incompatible various Unix versions and derivatives were over time.
    – Raffzahn
    Commented Dec 6, 2019 at 1:48

The -p option is a late addition. I did some checking and the Seventh Edition man page for ed doesn't mention the -p option, but it does appear in the Ultrix 4.2 man page. Fifth Edition Unix also doesn't mention a -p option, but it does say that if ed is invoked as a login shell (i.e. the program name provided in argv[0] is "-") that it will enable a * prompt. This was presumably done in support of the early use of Unix as a text editing system.

I am guessing that the -p option was added to provide an easier way to enable a prompt without jumping through the required hoops to invoke ed with arg[0] set to "-". But by that time, I suspect that very few people were still using ed for interactive editing: vi/ex and Emacs would have taken over for most. If you were still using ed, you were either familiar with it already due to using it for many years (in which case you wouldn't need the prompt), or you were using it non-interactively (giving it input from a file) and you wouldn't have wanted prompts anyway.

  • The P command was first found in UNIX System III. I think the -p option was first added in UNIX System V. Commented Mar 21, 2020 at 19:23

Looking at the previous answers I see everyone has missed an essential feature most system run level 1 commands, and that is that they were amenable to piping. The non-interactive mode is therefore the default in ed, ex, sed, awk, grep etc

TFTP (Trivial FTP) is also another good example of a stripped down version of FTP used in disk-less boot-up processes to boot from a remote network boot image. No user prompts are emitted as is done in the full-blown FTP.

  • 2
    I see why you wouldn't prompt when stdin was not a tty, but that in itself doesn't explain the lack of a prompt when stdin is a tty.
    – dave
    Commented Dec 8, 2019 at 21:00
  • It is not easy to apprehend the situation of prior eras. An earlier answer mentioned that the editing was done in one's head, not on the teletype. That applied to many other subtleties. Ed column numbers matched the imagined document, and column 1 was where imperative text went just as in the intended memory copy. So whence the prompt?
    – MKhomo
    Commented Dec 8, 2019 at 21:50
  • It's easy enough to apprehend a prior era when one remembers actually driving a teletype in said era. :-) Apropos 'column numbers', sure, the first character entered on a line was logically "column 1", but since teletypes don't actually have numbered columns, there's no problem if "column 1" is printed after a "*". In any case, I understood the question to be about a prompt in command mode, not in text-input mode, so column numbers aren't really a consideration.
    – dave
    Commented Dec 8, 2019 at 21:56
  • I lost some edits after the prompt? question in my prior comment. But perhaps I could reverse the apprehension issue by asking what purpose one would suggest the prompt would / should serve within the scope of 'ed' functionality which does recognize line and column numbers? As far as I remember it was to perform edit actions on the 'ed' buffer, although the bang (!) allowed escape to shell. Don't recall if 'ed' supported multi-buffer yank / put etc
    – MKhomo
    Commented Dec 8, 2019 at 22:20
  • I see no useful role for the prompt when in insert mode. I think a prompt is useful in interactive command mode since it conveys "done that thing, ready for the next thing". But then, I'm just describing all of the various non-display-oriented editors used.
    – dave
    Commented Dec 8, 2019 at 23:39

Because of the universality of printing terminals when ed was current. An editor prompt on each data line would have consumed space on the paper, which would have cut that much off of what you could type into each line, and see. Printing terminals didn't autowrap, and typing blindly off the end of the line was Unpleasant. Even if they had autowrap, that would have consumed more paper, and reduced the correspondence (on paper) between what you had typed the first time, versus what you'd see if you then printed it again (sans prompts). (Conservation of paper was a significant issue, even if it was just to prevent you from becoming mired in an overlarge pile of paper from your session.)

  • I'm not talking about data lines. I'm talking about command mode. The point is to be clear about what mode you're in. By default it doesn't give you a prompt even in command mode. It's very confusing to not be sure whether you're in command or data entry mode.
    – JoelFan
    Commented Mar 18, 2020 at 16:48
  • 3
    If you weren't sure you would just scan up the paper to see what you had done recently, it really wasn't too hard to tell what mode you must be in at the moment. Also, most text interpreted as commands would piss ed off in some way, and the "?" was a pretty good clue that you'd guessed wrong.
    – jimc
    Commented Mar 18, 2020 at 16:52
  • 4
    Life on a 10-cps printing terminal really was different in a lot of ways, it's hard to envision this if you've never had to live it.
    – jimc
    Commented Mar 18, 2020 at 16:57

A bit late in the day, but here's a timeless broad-brush non-explanation that quashes the OP question. It's from Queen Mary's College Univ of London - of all places.


Someone asked for a synopsis; so I'll do it in little bits as per reader reactions. First the one-page story. Two personalities appear in the Unix Editors story but if one goes back a little (during MULTICS predecessor phase) one discovers more central actors. In this case it is George Coulouris (GC), part of the UK side of the MULTICS. Folklore (and GC confirms here) has it Ken Thompson (KT) wrote ed and was quite happy not seeing the final / intermediate editing result as he merely kept it in his head. Input was teletype and 'seeing' it meant teletype printing the buffer which was a distraction (as would be the printing of a prompt). The UK crowd had a small Amiga dedicated-cpu terminal/console being developed that provided more capability which GC exploited at Queen Mary College at Univ of London, and named it "ED for Mortals" as a rejoinder and in deference to KT's standing and Editor (ED). So the quibbles over return prompt take on a different level of importance for that time. And this was during MULTICS and KT was the author of the ED being discussed here while QC of EM.

Secondly, GC and his collaborators across the British Computer Science fraternity had begun addressing the editing into rapid response one character at a time as an improvement on the one line at a time on hitting 'return'. So QC's EM did one response per char and when he installed it at U of C Berkeley the sysadmins there who had visual displays rejected it as too expensive on their multi-user UNIX CPU. It was Bill Joy (BJ) the Pascal Compiler BSD (Berkeley Software Distribution) guy who showed GC around and eventually extended GC's EM into EX and then into EX's 'open buffer command' Vi with the facility of 'raw mode' recently made available in DEC Virtual Terminal devices. Until then teletypes were truly Dumb Terminals as IBMers called them.

I'll stop here to not spoil it for those that might want to browse the QMCL.ac.uk link for themselves.

Side Note: During QC's stint at Berkeley the hot thing going then, he says, was the creation / development of Ingress. I think IBM had not long before released the definition of RDBMS into the public domain. Remember, Ingress was the mother of Postgress, the Auntie of Sybase, the God Mother of Informix and Grand Mother of MS SQL Server ...

The other minor historical is that BSD (Berkeley Software Distribution with the Regents U o C Copyright Notice and all) as a distribution of UNIX was pretty much predated in the Software Distribution by Bill Joy of his Pascal Compiler. UNIX (more or less mainly him again) came later under his 'Frienzied' PhD years there adding plenty core tools into BSD UNIX including building the TCP/IP stack from scratch (a first ever) after throwing out the 'IMPS' buggy and RFC-outdated variant that came with AT&T UNIX.

There's a lot more that was happening in frenzied fashion at Berkerley. Another big intersection was Bill Joy with the goings on at MIT that eventually got James Gosling to join them years later at SUN Microsystems (R.I.P), to eventually put together the ultimate byte code interpreter Mother of all interpreters we now call JVM Java. Despite all the Lore one hears, Emacs as we know it might have never come to being were it not for that same JG.

Last nugget (could'nt resist): That UK Amiga was also the basis of all the ARM architecture design that rules the embedded and SoC worlds today.

  • Hey - it's cool to have links to other resources but it's best to post the gist here too - links tend to break over time!
    – Matt Lacey
    Commented Nov 9, 2022 at 15:55
  • OK, I'll give it a shot.
    – MKhomo
    Commented Nov 9, 2022 at 21:25

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .