(OLDER) <- More Stuff -> (NEWER) (NEWEST)
Printer Friendly Version



More reasons to love Unix/Linux


2006/11/27

I did a lot of clean-up work at this website over the long Thanksgiving weekend. This was all due to radically changing the layout. Some of that was quick and simple do do, but for older pages I needed to do some hand editing before switching to the new format.

As I was working on that, I remember wondering how on earth I would ever have been able to do it if I ran this site on a Microsoft server. I'm not saying it couldn't be done, of course, just that it would have taken longer and would have been more frustrating. It is true that I could use Perl or some other Windows available scripting language, or have installed Windows Services for Unix or MKS Toolkit, but sheesh: why pretend when you can have the real thing?



Of course I did use Perl for a lot of it. For example, this simple script did a lot of the necessary work:

#!/usr/bin/perl
$file=shift @ARGV;
print "$file\n";
open(F,"$file") or die "$!";
@lines=<F>;

open(F,">$file") or die "$!";
   foreach (@lines) {
       s/xmlheader"/xmlheader2"/;
       s/div id="page"/div id="doc3"/;
       s/onepage.pl/newpage.pl/;
       print F $_ ;
       }


But that wasn't enough to handle everything. Some of the rest I did with other Perl scripts, some with sed, grep and the other usual Unix tools. Here's a little one liner I found very handy for showing me what I still needed to work on:

grep -L "$1" *.html
 

Basically that quickly shows you the files that do NOT contain whatever pattern you give it. If you are working on a very old system without -L, this script will do a similar job:

grep -l "$1"  *.html >~/a
ls *.html > ~/b
diff ~/a ~/b | sort
 

Another helpful little bit is this:

grep -h "$1"  *.html | sort -u
 

That helps for identifying what other editing scripts will have to be looking for.

Probably most missed would have been Vi and the ability to pass portions of a file for editing by external scripts. Something as simple as

:16,25!myedits
 

(where "myedits" is a Perl, sed or whatever script containing multiple editing commands) can save hours, as can assigning repetitive tasks to macros.

I'm not 100% done with the cleanup. There are still parts of the site I haven't gotten to, and other parts where I just did the bare minimum and need to return for more work. But it is largely complete, and I'm reasonably happy with the new look. I hope the readers agree.




Click here to add your comments



Don't miss responses! Subscribe to Comments by RSS or by Email

Click here to add your comments


If you want a picture to show with your comment, go get a Gravatar



ad

Have you tried Searching this site?

Unix/Linux/Mac OS X support by phone, email or on-site: Support Rates

This is a Unix/Linux resource website. It contains technical articles about Unix, Linux and general computing related subjects, opinion, news, help files, how-to's, tutorials and more. We appreciate comments and article submissions.

Publishing your articles here

Jump to Comments



Many of the products and books I review are things I purchased for my own use. Some were given to me specifically for the purpose of reviewing them. I resell or can earn commissions from the sale of some of these items. Links within these pages may be affiliate links that pay me for referring you to them. That's mostly insignificant amounts of money; whenever it is not I have made my relationship plain. I also may own stock in companies mentioned here. If you have any question, please do feel free to contact me.

Specific links that take you to pages that allow you to purchase the item I reviewed are very likely to pay me a commission. Many of the books I review were given to me by the publishers specifically for the purpose of writing a review. These gifts and referral fees do not affect my opinions; I often give bad reviews anyway.

We use Google third-party advertising companies to serve ads when you visit our website. These companies may use information (not including your name, address, email address, or telephone number) about your visits to this and other websites in order to provide advertisements about goods and services of interest to you. If you would like more information about this practice and to know your choices about not having this information used by these companies, click here.


book graphic unix and linux troubleshooting guide

My Troubleshooting E-Book will show you how to solve tough problems on Linux and Unix systems!



 I sell and support
 Kerio Mail server




pavatar.jpg
More:
       - Opinion


Unix/Linux Consultants

Skills Tests

Guest Post Here











My Favorites

Change Congress