If you’re in the tech field, it might behoove you to know your command line utilities, and to have a copy of Cygwin handy if you run Windows. There are reasons why those old-school UNIX guys look down their long beards at the rest of us with disdain for not knowing the system shell. I ran across a great use of command line tools today that I thought I’d share.
I opined a few months ago on the beauty and joy of the command line, but I had another experience today that really illustrated the fact that GUI’s aren’t the best tool for everything. I have both the privilege and burden of dealing with Rational Clearcase for some version control…
You could also use Rebol http://www.rebol.com to handle most of this in a few short lines of code (including the wget piece of this). Although it's a bit more verbose, the code would likely be much more readible and simpler for those unfamiliar with shell scripts.
For example, the sed part can be accomplished with the following parse statement:
IDs: [] parse/all read %transfer.log [ any [thru "cid=" copy ID to newline (append IDs ID)] ] sort IDs
It's always gratifying to solve something tedius with a shell script, and I'm not saying my way is better. If your interested in more info, I can post a short article that lists & exmplains the REBOL code for this entire task. The code would probably be 15 lines or so.
Looking more closely at the wget log, I need to correct the parse code to:
parse/all read %transfer.log [ any [thru "?cid=" copy ID to newline (append IDs ID)] ]
The only change is the "?" in the match pattern. This makes sure we exclude the other lines of the log that have "@cid=" in them.
Ficke dich!