Question Marks in ed

I typed the following commands:

Code:

176 lab2-37:~> ed newb.txt
74
1,6p
Hello
Hello World.
I need some sentences to edit.

add the script
OK Fn
2,4c
.
1,3p
Hello
add the script
OK Fn
q
?

Please note the second-to-last line: I want to quit the ed, so I typed q, but instead of quitting immediately, the ed gave me a question mark, why?

----------------------------------------------------------

You had not written the file. Another q will exit.

----------------------------------------------------------

Thanx. I know why now.

Code:

     If changes have been made in the buffer  since  the  last  w command  that wrote the entire buffer, ed will warn the user
     if an attempt is made to destroy the editor buffer via the e or q commands. The ed utility will write the string:

     "?\n"

     (followed by an explanatory message if help  mode  has  been enabled  via the H command) to standard output and
     will continue  in  command  mode  with  the  current   line   number unchanged.  If the e or q command is repeated with
     no intervening command, it will take effect.

----------------------------------------------------------

I'm a little bit confused about ed. What's the use of ed since there are such more powerful editors like vim, emacs, etc.?

----------------------------------------------------------

ed is a really old editor, and beleive it or not, there are old systems like telephone switches that the only text editor available is ed. This is when I learned it and still use it.

Another use is when you have several things in a window you want to paste into a file, but don't want to lose it (by opening vi), you can use ed and accomplish this. Of course a second window will do the same thing.

Given the choice, most people will use vi (including me).

Have a Unix Problem
Do you have a UNIX Question?

Unix Books :-
UNIX Programming, Certification, System Administration, Performance Tuning Reference Books

Return to : - Unix System Administration Hints and Tips

(c) www.gotothings.com All material on this site is Copyright.
Every effort is made to ensure the content integrity.  Information used on this site is at your own risk.
All product names are trademarks of their respective companies.
The site www.gotothings.com is in no way affiliated with or endorsed by any company listed at this site.
Any unauthorised copying or mirroring is prohibited.