Archive for the ‘System Administration’ Category

Running the script you are currently editing in vi

Tuesday, April 24th, 2012

Instead of doing all the typing involved with leaving your vi session to run the script you just edited, you could simply type

:!%

“%” is a shortcut for the current filename. For this to work, the current file (%) should be in your $PATH. Or if that’s inconvenient or unwise, you can always just make the call to the file’s absolute path by substituting % with the absolute path of the file. The file should be executable, which, if it isn’t, you change by typing

:!chmod +x %

Of course, if you have just created the file, you’ll need to do a :w to actually commit the file to the filesystem, before you can make any calls to it.

Remember to use

:!!

to repeat the last command you just ran from within vi to save yourself more typing.

VI Cheat Sheet

Monday, May 17th, 2010

Replace commas (or something) with line breaks (or something)

:%s/,/^M/g
where ^M = ctrl+V & ctrl+M

Use vi to comment out (or do something else to) several consecutive lines

Example: If you wanted to comment out lines 20 to 40 of a file, use the following:

:20,40s/^/# /

Use

:set number

to enable visible line numbers.

Rant: Sun’s Web Site

Thursday, August 14th, 2008

I sent a message to Sun after a frustrating afternoon trying to get a patch cluster to patch my personal Sun server. The grammar and wording sucks, but I was completely pissed (and it’s been building up over the last 3-4 years trying to use their awful web site).

Subject: Your Website: Awful!

I’m trying to download the 10_Recommended patch cluster. 3-4 successive attempts to download the 600+ MB file completed after 220MB leaving me with a corrupt file. It took me 5-10 minutes to actually even find the page containing the patch cluster to begin with. Then I learned that I needed to be logged in to download the cluster. But I wasn’t given a login prompt, I was just given an error page. I had to go back and search the previous pages for a login prompt. Overall your site has, for the last 2-3 years, completely sucked. Why don’t you help the people who use your products by making things easier to find, and making them available (not by filling our hard drives with corrupt zip files)? Also, don’t make people log in to read your precious tech docs and spec sheets. That’s completely stupid too.

I used to think the people I worked for were crazy for dumping Sun for Dell/Windows, but now I see that you seem to be too inadequate to handle the business people give you. I guess you’ll be going the way of Sco Unix before long. Can’t say I’ll be that sorry to see you go when you do.