Boot fail, please help!

Geraint Edwards gedge-lists at yadn.org
Sun Oct 29 07:43:27 GMT 2006


Spadge Fromley <spadge at fromley.net> said
		(on Thu, Oct 26, 2006 at 04:23:40PM +0100):
> > On 10/26/06, Spadge Fromley <spadge at fromley.net> wrote:
> >> Seriously, I detest vi so much that when I am stuck with having to edit
> >> a file in single user mode with no other editor available, I will always
> >> choose 'cat | sed' :D

> Hey, don't knock it; it works :D

But what works for you is just as -erm- detestable as the thing
you're avoiding!  :-)

Firstly, you do the classic "useless use of cat" here, where
redirection is generally better.

Secondly, you can get sed to do the backup for you (-i flag),
saving on the mv(1).

When your substitution/string in sed is "slashy" (and hence ugly
to escape within s///), use another delimiter (e.g. replace the
sed command s/// with s@@@, perhaps).

Also, you use the global flag 'g' in the s///g, when there can
only be one match on any line (since you've anchored the pattern).

Lastly, when you're replacing the found string in the replacement
text, use the magic '&' to save typing/errors.

So, your lines:

	mv /etc/fstab /etc/fstab.old
	cat /etc/fstab.old | sed 's/^\/dev\/ad1s1d/\#\/dev\/ad1s1d/g' > /etc/fstab

could be replaced with:

        sed -i.old 's@^/dev/ad1s1d@#&@' /etc/fstab

But, then, I'd still use vi... :)

	vi /etc/fstab			# subsequent lines are entered into vi
		/^\/dev\/ad1s1d<Enter>	# search for line with pattern
		I#<Escape>		# insert a # at start of this line
		n.			# repeat search (n), repeat insert (.) as necessary
		ZZ			# save and quit

-- 
Gedge




More information about the Ukfreebsd mailing list