grep, in PowerShell

Here is a sample of a PowerShell script that I use for finding text in files, having “grown up” with a more Unix-like syntax. I know, this isn’t exactly a clone of grep‘s functionality, but it gets me closer than having to remember exactly how to wrangle PowerShell’s Select-String commands to my liking. Note that I normally am looking for things recursively, so my script does that automatically.

Param(
  [string]$filename,
  [string]$target
)
ls -r $filename | sls $target

I call that by using an alias, set in my $PROFILE

Set-Alias grep c:\code\ps\Grep.ps1

Then I can just use a command like one of these

c:\> grep \code\*.ps1 version
c:\> grep *.txt hobbits
c:\> grep $HOME alpharetta

Also available, with any changes since this was published, in this repo.

On Measurement

a coinI read this the other day, as part of a discussion about monies; in particular the fact that at one point in history not all currencies were divided into decimals, as the US Dollar is (ten pennies = one dime, ten dimes = one dollar). I believe it’s originally from Terry Pratchett’s book Good Omens:

“Two farthings = One Ha’penny. Two ha’pennies = One Penny. Three pennies = A Thrupenny Bit. Two Thrupences = A Sixpence. Two Sixpences = One Shilling, or Bob. Two Bob = A Florin. One Florin and one Sixpence = Half a Crown. Four Half Crowns = Ten Bob Note. Two Ten Bob Notes = One Pound (or 240 pennies). One Pound and One Shilling = One Guinea.

In the UK they resisted decimal currency for a long time because they thought that “100 pennies to 1 pound” was too complicated”

In comparison, I offer this:

Twelve inches = one foot. Three feet = One Yard. 1,760 yards (or 5,280 feet, or 63,360 inches) = One Mile.

Is “100 centimeters to 1 meter, 1000 meters to 1 kilometer” really too complicated for us in the U.S.?

Open letter to Capital One

To the officers and marketing director at Capital One:

Go away. Stop bothering me. I don’t want your credit card. My wife doesn’t want your credit card. My children don’t want your credit card. Above all I don’t want the advertisements and “pre-approved offers” your company is dropping into my mailbox almost every day. If I didn’t reply, didn’t accept the first 100 you sent, what makes you think I’ll reply positively to the 101st? or 102nd? Just stop already, enough is enough.

Your seemingly-endless stream of crap in my mailbox is doing nothing positive for your company’s image. You’re becoming the laughing stock of the early 2000’s mailbox, just as AOL was in the 1990s with thier endless disks.

Just go away.

Creating Custom Ringtones

Over a cup of coffee at Starbucks this morning Eric asked me about the custom ringtones on my mobile phone, specifically how I get exactly what I want and how I transfer it to the phone. I’ve looked through the software shelves at Fry’s, BestBuy, CompUSA and other places, and there are lot of packages you can buy to create and transfer ringtones. But hey, I’m a geek so I take the more adventurous – and less expensive – route.

I use iTunes to “rip” my music to .mp3 format from CDs, of course Windows Media Player and plenty of other applications will do likewise. There are plenty of choices for you there.

I then use Audacity to edit the songs or sounds to a reasonable length (10-15 seconds is more than enough). The trick there is that you can’t “open” an .mp3 file, you go to the Project menu and choose Import Audio. Likewise, when you’re done you use Export MP3 from the File menu, rather than Save. (Open and Save are for Projects, which can include multiple sound tracks. This is a very powerful program, nicely impressive for free, open source software.)

To get the final sound file to my phone, SmashWorld’s Mobile17 service works well for me. They claim to work with “94% of popular, every-day mobile phones,” and fortunately mine is one.

Sign up, choose your phone and service, and it’ll show which sort of files you can transfer – each phone/service combination can be different.

Mobile17 has two options when it actually comes to transferring your files, free and express. If you don’t mind waiting, you can choose the free option and you’ll get put in a queue with everyone else. If you’d like to make a donation, you can get moved toward the front of the pack. Either way seems to work just fine; I’ve used the Free option and gotten my ringtone transferred in as litte as 5 minutes or as long as an hour. If you don’t mind waiting, no problem. If you do, you have the option of paying. That’s pretty reasonable.

Rip, Edit, Transfer. It’s easy and can be completely free.

Advice to Cingular and ATT Wireless Customers

“Your world just got a lot bigger,” Cingular and AT&T Wireless ‘cell phone’ customers are being told, and the TV advertisements proclaim that they can now talk with all 46,000,000 subscribers “for free.”

Well, it’s true that the two companies are now one and have a large combined subscriber base. And it’s also true that all those people now have the opportunity to talk with each other without using any of their plan minutes. “Free.” “Mobile to Mobile.” Call my wireless phone, talk with me for an hour and still have all your minutes remaining. Yes, Virginia, that’s a good thing.

The key word there is opportunity, though. From the large brochure:

If I don’t have Mobile to Mobile calling on my current plan, will I automatically get it?

No, but adding it to your existing plan or switching to a plan that includes Mobile to Mobile is easy. To learn more, visit www.cingular.com.

If you’re a Cingular customer, or if you were an AT&T customer, do yourself a big favor and stop by your local Cingular store and look at the new contract offerings. If you’ve got multiple phones in your household, be sure to ask about the FamilyTalk plans, too. You won’t regret it.


btw, I called them ‘cell phones’ above, though I’m told that what most of us use these days – digital phones using GSM – aren’t really “cellular” at all. It’s the common term, though. Like ‘dialing”‘a phone… are there any phones with real dials anymore?

FTC: How Not to Get Hooked

Internet scammers casting about for people’s financial information have a new way to lure unsuspecting victims: They go “phishing.”

Phishing is a high-tech scam that uses spam or pop-up messages to deceive you into disclosing your credit card numbers, bank account information, Social Security number, passwords, or other sensitive information. …

The FTC, the nation’s consumer protection agency, suggests these tips to help you avoid getting hooked by a phishing scam…

If you’re using the net – and obviously you are – invest a few minutes in reading this Consumer Alert.

Oh, and if you haven’t already, please consider installing SP2 (but remember that it’s only a starting point for security) and/or using other pop-up blocking software.

Destiny Day

October 13, 1492: At daybreak great multitudes of men came to the shore, all young and of fine shapes, and very handsome. … I was very attentive to them, and strove to learn if they had any gold. Seeing some of them with little bits of metal hanging at their noses, I gathered from them by signs that by going southward or steering round the island in that direction, there would be found a king who possessed great cups full of gold.

October 14: I could conquer the whole of them with fifty men and govern them as I pleased.

from Lies My Teacher Told Me, by James W. Loewen

And so Christopher Columbus (a.k.a. Cristoforo Colombo) arrived in the “New World” on October 13, 1492. A Dutch sailor reportedly persuaded him to change his log to October 12th for fear the 13th might trouble both the superstitious sailors and potential investors, though most current versions of History mark the 13th as the date of discovery. According to one report I heard on the radio this weekend, the 13th is “Destiny Day.”

Bonus points for you if you can tell us which island Columbus “found” first.

Today in the USA, Columbus Day is one of these floating Monday holidays — so that most governmernt offices can close and thus give some people a three-day weekend — and this year that means we’re actually celebrating the right day.

Of course, that all completely ignores Leif Ericsson and Bjarni Herjulfsson, neither of whom had as good a marketing campaign as Columbus did.