HOWTO: The famous Mister Ed
Posted: Mon Oct 28, 2013 5:11 am
[yt]y_PZPpWTRTU[/yt]
The GNU line editor. It can save some serious ass. Let's create a file, save it, edit it, move stuff around.
Starting 'ed'
ed is not always included, so you might wat to install it. Have a try, in your terminal, enter
Ed is now waiting for input, this is the command mode. Not quite obvious? Let's change the prompt:
which brings up an asterisk as prompt. In the future you can start ed, showing a prompt like "Ready:" the next time using ed -p Ready:
Creating a new file
Creating a new file happens by appending lines to the existing file (which is of course not existing yet), so let's append:
and start to type. Hitting enter bring the newline, and we stay in append mode. When you finished, hit Enter and type a period. That's how it looks like from the start to here:
Remember, the asterisk is our command prompt, so now ed is waiting for input.
Save and Quit
Let's just imagine we want to write this file to disk and then quit (much like :wq) - save it as 'pensi.txt'
and let's quit:
If we enter a
it is similar to vi's :q! - an unconditional quit: all changes are lost.
Tomorrow: edit an existing file, search and replace.
The GNU line editor. It can save some serious ass. Let's create a file, save it, edit it, move stuff around.
Starting 'ed'
ed is not always included, so you might wat to install it. Have a try, in your terminal, enter
Code: Select all
ed
Code: Select all
P
Creating a new file
Creating a new file happens by appending lines to the existing file (which is of course not existing yet), so let's append:
Code: Select all
a
Code: Select all
bbq@grill $ ed
P
*a
This is line 1
And this is line 2
This is the last line.
.
*
Save and Quit
Let's just imagine we want to write this file to disk and then quit (much like :wq) - save it as 'pensi.txt'
Code: Select all
w pensi.txt
Code: Select all
q
Code: Select all
Q
Tomorrow: edit an existing file, search and replace.