DaemonForums  

Go Back   DaemonForums > OpenBSD > OpenBSD General

OpenBSD General Other questions regarding OpenBSD which do not fit in any of the categories below.

Reply
 
Thread Tools Display Modes
  #1   (View Single Post)  
Old 16th May 2009
unicyclist unicyclist is offline
Fdisk Soldier
 
Join Date: May 2008
Posts: 54
Thanked 2 Times in 2 Posts
Default cheatsheet for ed

On 2 different occasions, I've made a mistake on my system(s) and when rebooted, I was left with single user/root prompt and nothing to use but ed. I've read the man page for ed a few times, but just can't "get it". Is there a cheatsheet somewhere that I can print?
I tried googling, but couldn't get a hit on what I was really after.
If/when I make another mistake like that, I want to be ready
Thanks.
Reply With Quote
  #2   (View Single Post)  
Old 16th May 2009
DrJ DrJ is offline
ISO Quartermaster
 
Join Date: Apr 2008
Location: Gold Country, CA
Posts: 506
Thanked 39 Times in 39 Posts
Default

http://www.catonmat.net/blog/ed-unix...r-cheat-sheet/
Reply With Quote
  #3   (View Single Post)  
Old 16th May 2009
Oko's Avatar
Oko Oko is offline
Fsck Surgeon
 
Join Date: May 2008
Location: Kosovo, Serbia
Posts: 774
Thanked 36 Times in 32 Posts
Default

As long as you can mount /usr you will be able to use /usr/bin/vi but you must export the term before start editing
Code:
mount /usr
export TERM=vt220
Ex is just enhanced version of ed so this should help.

http://www.openbsdsupport.com.ar/books/vi/ch05_01.htm
Reply With Quote
  #4   (View Single Post)  
Old 16th May 2009
TerryP's Avatar
TerryP TerryP is offline
Arp Constable
 
Join Date: May 2008
Location: USofA
Posts: 1,547
Thanked 112 Times in 104 Posts
Default

From a working system, you can also learn more about the functioning of ed, by reading the documentation

In /usr/share/doc/usd are files from the UNIX User's Supplementary Documentation (USD), including entries for ed, ex, vi, sed, and awk (sadly the usd for troff and macro packages are not installed, but you can get them online). Makefiles are present for building them in postscript / text format, most can also be manually processed with nroff and fed into ed or a pager.


take a look at 09.edtut, and 10.edadv after that, you should be able to use ed effectively -- it is actually a very good tool, especially if a network connection is light, and a more modern line editor is not available. (e.g. vim followed by gQ command, or sam).
__________________
My Journal

Thou shalt check the array bounds of all strings (indeed, all arrays), for surely where thou typest ``foo'' someone someday shall type ``supercalifragilisticexpialidocious''.

Last edited by TerryP; 16th May 2009 at 08:38 PM. Reason: Typo fixed, thx unicyclist
Reply With Quote
  #5   (View Single Post)  
Old 16th May 2009
unicyclist unicyclist is offline
Fdisk Soldier
 
Join Date: May 2008
Posts: 54
Thanked 2 Times in 2 Posts
Default

Thanks for all the help. Something new for me in each comment
Terry, fwiw, usd is under /usr/share/doc in OpenBSD. I had to run locate to find it
Reply With Quote
  #6   (View Single Post)  
Old 16th May 2009
TerryP's Avatar
TerryP TerryP is offline
Arp Constable
 
Join Date: May 2008
Location: USofA
Posts: 1,547
Thanked 112 Times in 104 Posts
Default

Oops, typo -- corrected, thanks!
__________________
My Journal

Thou shalt check the array bounds of all strings (indeed, all arrays), for surely where thou typest ``foo'' someone someday shall type ``supercalifragilisticexpialidocious''.
Reply With Quote
  #7   (View Single Post)  
Old 31st May 2010
unicyclist unicyclist is offline
Fdisk Soldier
 
Join Date: May 2008
Posts: 54
Thanked 2 Times in 2 Posts
Default

Terry, I had another reason to use ed:
I reformatted a partition that was listed in my fstab file so when I rebooted OpenBSD...
Using ed, I was able to change the affected line (changed from dos to ext2).
I'm really getting to like the simplicity of ed, and getting quite fond of it. Even using it when I'd normally us vi.

Thanks again to all of you for help/url's
Reply With Quote
  #8   (View Single Post)  
Old 1st June 2010
TerryP's Avatar
TerryP TerryP is offline
Arp Constable
 
Join Date: May 2008
Location: USofA
Posts: 1,547
Thanked 112 Times in 104 Posts
Default

If using ed regularly, you might also like to look into one that has a command history, like GNU ed. Its a bit more readline esque than BSDs version.

You might also like to try Rob Pikes 'sam' editor.
__________________
My Journal

Thou shalt check the array bounds of all strings (indeed, all arrays), for surely where thou typest ``foo'' someone someday shall type ``supercalifragilisticexpialidocious''.
Reply With Quote
  #9   (View Single Post)  
Old 1st June 2010
BSDfan666 BSDfan666 is offline
Real Name: N/A, this is the interweb.
Helpful companion
 
Join Date: Apr 2008
Location: Ontario, Canada
Posts: 2,223
Thanked 193 Times in 184 Posts
Default

You might also like ex(1), which is a line-editor like ed, but compatible with vi.
Reply With Quote
Old 1st June 2010
thirdm thirdm is offline
Package Pilot
 
Join Date: May 2009
Posts: 205
Thanked 3 Times in 3 Posts
Default

The Unix Programming Environment, Kernighan and Pike. Not a cheat sheet of course, but a book worth having, and not hard to find what you need to know about ed in it. Usually when I need ed, I don't have /usr mounted anyway, so having something on paper describing it is good. If you're going to get this book anyway, having it will save you printing ed(1).
Reply With Quote
Old 1st June 2010
unicyclist unicyclist is offline
Fdisk Soldier
 
Join Date: May 2008
Posts: 54
Thanked 2 Times in 2 Posts
Default

thirdm, I'll have to watch for that book. Not working right now, though, so already printed the files under /usr/share/doc/usd
BSDfan666, I've looked at ex and have been reading the link that Oko gave. Thanks

Don't recall reading about "sam". Will have to at least read about it, but right now I'm happy knowing that I can use ed to fix text problems. Don't want to overwhelm the grey matter more than it already is

Thanks again everybody
Reply With Quote
Old 1st June 2010
TerryP's Avatar
TerryP TerryP is offline
Arp Constable
 
Join Date: May 2008
Location: USofA
Posts: 1,547
Thanked 112 Times in 104 Posts
Default

Quote:
Originally Posted by BSDfan666 View Post
You might also like ex(1), which is a line-editor like ed, but compatible with vi.
Only if you switch it into "vi[usual]" mode, than it becomes compatible with vi . The progression was ed -> sth else -> ex -> vi. I forget what line editor it was birthed off but it was based on ed iirc. The nvi implementation providing vi and ex for the BSDs is still lacking, unless the special vi keys for ex command history/filename completion work without having to be done from visual modes :.
__________________
My Journal

Thou shalt check the array bounds of all strings (indeed, all arrays), for surely where thou typest ``foo'' someone someday shall type ``supercalifragilisticexpialidocious''.
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 01:14 AM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content copyright © 2007-2010, the authors
Daemon image copyright ©1988, Marshall Kirk McKusick