sh: “split” Shortcut

Link: https://dannyman.toldme.com/2007/08/22/sh-split-via-set/

Recently, I wrote a shell script that had to break an IP address into octets. I wrote:

# octects
oct1=`echo $subnet | awk -F . '{print $1}'`
oct2=`echo $subnet | awk -F . '{print $2}'`
oct3=`echo $subnet | awk -F . '{print $3}'`
oct4=`echo $subnet | awk -F . '{print $4}'`

Later, when reviewing my script, Anonymous Coward offered this little gem:

$ set `echo | tr '.' ' '`
$ echo $1
$ echo $2
$ echo $3
$ echo $4

Which means, you can just set a series of variables to $1, $2, $3, and so forth. In Anon’s example, the IP address is split into words with tr, and the variables set nice and easy with set.

Of course, if your script gets complex, you probably want to avoid relying on those variables. My original code could be re-expressed:

set `echo $subnet | tr '.' ' '`
oct1=$1; oct2=$2; oct3=$3; oct4=$4

Much nicer than invoking awk several times.


About Me, Featured, News and Reaction, Technology

Cable TV vs. Satellite TV

Link: https://dannyman.toldme.com/2007/08/24/television-just-say-no/

[From a discussion I recently engaged.]

Q: What are the pros and cons of cable versus satellite in terms of cost, features, and quality of service?

Television’s Best Deal (CC: dsasso.)

A: This isn’t for everyone, but here is the deal I am on right now:

$14/mo for Netflix
$12/mo for DSL
$26/mo Video+Internet

This lets me watch a few movies each week, and when I really want to watch TV I can download the “Daily Show” with the commercials already edited out from BitTorrent. Since adopting this plan I have gotten more into the “shopping for my own food and cooking it myself” channel, the “tidying up and arranging my own apartment” channel, the low-key reality show “can dannyman take care of these flowers” and some call-in shows featuring friends and family. I’m considering some plus packages like “my new pet” and maybe “learn a musical instrument” but I haven’t even gotten in to the last one I tried: “Mandarin Chinese”

One of the big drawbacks to this approach is that there’s not much of a channel guide to help me keep track of all the possibilities, and good luck finding a universal remote! On the other hand, the commercials are pretty rare and innocuous, so you don’t need a DVR.


Feedback Welcome

Free Style, Relationship Advice, Sundry, Testimonials

One Brick

Link: https://dannyman.toldme.com/2007/08/24/volunteer/

Cool things I have come into as a consequence of volunteering with One Brick these past few months:

Or, as Saint Francis put it: “it is in giving that we receive.”

If you are looking for fulfilling ways to spend your free time, I heartily recommend One Brick, which is very simply an organization that organizes volunteer opportunities: just sign up for their e-mail list and every week you’ll be informed of cool opportunities to get out, do some good, and make friends.

I am looking forward to working the Elks Club Card Night next month, so much that I posted the event to Yelp to see about getting more folks over there.

1 Comment

Letters to The Man, Sundry, Technology

Yahoo! Insiders

Link: https://dannyman.toldme.com/2007/08/29/yahoo-insider-search-assist/

I recently participated in some beta test challenge thing for something called Yahoo! Insiders. They sent me some schwag, including a nice little flashlight that came without the requisite 3 AAA batteries, and a cute little USB mouse that is too tiny for my massive hand. The program consisted of 9 “challenges” which basically boiled down to “use our search engine to find the answer to this question and you might win a prize.” (The prizes were nice, one day was a nice digital camera.) The search engine had some “suggestions” of what search terms you might be better off searching, which would appear if you clicked a little widget. Kind of like the Google spell checker, but with synonyms.

I didn’t use the feature because, well, it was buried under a widget and because I’m pretty good with typing keywords into search engines. I’m guessing they think “suggested keywords” might do something for newbies, though it really isn’t clear.

They just solicited some feedback. I filled out the form, and at the end they asked “is there anything at all that you would like us to know about Yahoo!, The Yahoo! Search Insiders Program or Yahoo! Search Assist?” I thought a moment, then:

What are you trying to accomplish? Build a slightly better search engine? Google works awfully damn well 90% of the time, so the bar to get anyone to switch for “better” is extremely high. Maybe you can put your massive resources behind a more ambitious idea like combining social bookmarking with Netflix/Amazon-style “recommendations” and thereby build a more personalized “Page Rank” index using social networking . . . the sort of thing Google SUCKS at.

I sound like a big dork.

1 Comment

News and Reaction, Politics, Technology

Yahoo! Prefers Chinese Law

Link: https://dannyman.toldme.com/2007/08/31/yahoo-prefers-chinese-law/

Yahoo! is a California company. A few years back they complied with Chinese law to reveal the identity of Chinese dissidents who then became Chinese political prisoners. Now the dissidents are suing Yahoo! for violating a California civil rights law.

Yahoo! says:

“This is a lawsuit by citizens of China imprisoned for using the internet in China to express political views in violation of China law. It is a political case challenging the laws and actions of the Chinese government. It has no place in the American courts.”

Which, on the face of it, sounds fair, but Yahoo! made the choice to engage the Chinese government and Chinese law and thereby send Chinese citizens to prison. I don’t approve. And as a California resident, I figure Yahoo! is reaping what it sowed.

Feedback Welcome

« Older Stuff
Arrr! . . . Avast!
Site Archive