Wednesday July 14, 2004
MCWong
|
| Blah! MCWong |
|
ksh scripting #4 : list elements v7 and v8
Alan offered cool advise on ksh scripting #3 with ... and I dig!
So I adapted
Here's pl7() which adapted the
And to add some flexibility, I can cater to user specified delimiters which would have been otherwise messy to do in pl version 1:
Give it a go:
I guess my intention was clear, in that I'm trying to let
PS: Okay why version 7 and 8? it took me that no. of iteration to figure out IFS. ;) ksh scripting flashback: #1 #2 #3 (2004-07-14 00:00:04.0) Permalink Comments [3] ksh scripting #3: list elements It seem unavoidable, at some point there is always some kind of list that needs spliting.
Here's to give it a go:
Why '|' as separator? Well, when was the last time you see this '|' thing in the English language? And, when was the last time you process a bunch of shell command pipelines all concatenated together into a list to be processed? I supposed you get them more often with each pipeline on a separate line, as in a shell script (?!); which you could readily process with read, grep, awk, sed and a zillion other utilities. Why not ':' as in /etc/passwd? I have scripts that process list of URL's, so 'http://...'! Not very convenient isn't it.
ksh scripting flashback: #1 #2 (2004-07-09 00:00:03.0) Permalink Comments [1] ksh scripting #2: unix friendly filename Every time I rip and encode tracks from my CD collections (yes I still buy them) to mp3, I had the need of getting a unix friendly filename from the human readable title since I use Solaris to do everything. I typically grab the titles from a free cddb out there that happens to have my album's details. But these come in various formats such as:
While I need them to be unix friendly, such as:
So I script it with the help of
I'm not even sure if I understand this now that I looked at it again. :(
The ksh scripting flashback: #1 (2004-07-08 00:00:02.0) Permalink Comments [5] True to the tradition of unix, this is as cryptic as it gets, but... elegant [GEEK!]
For those who like filename with obvious indication of it's genre, e.g.
I always use
and any error output,
Since my job does more code reading than writing, what's left is the occasional need to automate some test, so shell does it just fine. Instant and disposable (i.e. no worries about reusable values). Nevertheless, there are a few tricks here and there that I like to remember.
(2004-07-07 00:00:01.0) Permalink While having my daily fix of Sun blog (kind of becoming yet another addiction), I came across hoffie's happy endorsement of downloading gaim from blastwave and interestingly traced to maintainer torrey. Hey, that's Torrey! Can't miss Torrey if you read email support aliases. >-) Since I had procrastinated too long to compile gaim 0.77 myself (got the source but not the time) and to think that 0.78 is already out, I figured, hey, why not, let's be lazy. I remember doing pkg-get some time ago when it was still BOLTpget.pkg, but can't recall what for; which means it probably failed for some reason. Anyway, this time, it was painless and by far the best user experience I've had installing free stuff! Installing anything for that matter! pkg-get -i gaim A couple of y's later for 'yes' to run script with su priv, Gaim 0.78 was up and running! That's all there is! Considering that I had an empty /opt/csw, so pkg-get were downloading obscene amount of packages that at some point I was actually worried. (Should I?) With such easy success, it didn't take long for me to continue with: pkg-get -i gqview And again, no problem whatsoever. This time was a lot faster considering most of the big dependent packages are already done. blastwave ROCKS! Here's yet another satisfied customer. :-) (2004-06-17 02:02:02.0) Permalink Comments [4] |
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||