Linux - SoftwareThis forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Then open it again and type 1,$n
Which will print all the lines with their line numbers.
This example is from an /etc/rc.conf on the live cd I am using.
Code:
1 background_dhclient="YES"
2 firewall_enable="YES"
3 firewall_type="open"
4 hostname="freesbie.livecd"
5
6 NIC="de em ixgb txp vx bfe bge dc fxp lge nge pcn re rl sf sis sk ste ti tl tx vge vr wb xl cs ed ex ep fe ie lnc sn xe an awi wi"
7
8 for i in $NIC; do
9 eval ifconfig_${i}0="DHCP"
10 eval ifconfig_${i}1="DHCP"
11 done
12
13 inetd_enable="NO"
14 moused_enable="YES"
15 saver="logo"
16 sendmail_enable="NONE"
17 sshd_enable="NO"
18 usbd_enable="YES"
19 background_fsck="YES"
If the line I wanted to delete was moused_enable="YES" I could use the number to tell ed to remove that line. 14d
Then save and exit w
q
Note: it is very wise to have some passing familiarity with ed (and vi) for the very situations like this one. Even if you personally don't like to use them. There have been times when it was only my knowledge of ed which saved me from reinstalling a system which would not behave enough to use a different editor.
Never used ed, but I'm sure I'm could if I had to. I always make sure pico or nano is installed. Very great easy to use in-console editors. You may want to see if you have one of them installed.
Originally posted by RoaCh Of DisCor Never used ed, but I'm sure I'm could if I had to. I always make sure pico or nano is installed. Very great easy to use in-console editors. You may want to see if you have one of them installed.
A problem that results in the need to use ed usually means the terminal can't be defined. You may no longer have a terminal definition file or whatever. So anything that would need a terminal definition to work wouldn't load. That would include pico, nano, and even vi.
ed is not very hard and actually will be very easy to use (at least the basics) if you have any experience with EDLIN from back in the long ago days of DOS.
Nothing like a good line editor to keep it simple and make changes.
Originally posted by jschiwal You may have 'vim-minimal' available.
That is possible but I am fairly certain that vim-minimal (which is installed as /bin/vi anyway) is still not going to work without any terminal definitions. Not that it really matters. If you are fairly comfortable with vi then using ed is not going to be a major issue.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.