May 5th, 2009 — Computers
Example using Cygwin gnu find, xargs and grep to search for a typo in XSLT and XML files. Note that -iregex matches a pattern in the whole path, and the pattern is a POSIX basic regex:
C:\>find ./ -iregex ‘.*\.\(xslt\^|xml\)’ -type f -print | xargs grep -i "staus"
When find matches a file path, the path is piped to xargs, which hands it off to grep to search for the string “staus” – which I want to replace with “status” (but not here :).
May 4th, 2009 — Computers, Society, Web 2.0, WordPress
Like Ruben, who provided the clues, I discovered that a corrupt/incompatible alternatives.lst.bz file in the C:\cygwin\etc\setup directory caused Cywin setup.exe to fail.
A few clues pointed to this file as the culprit:
- First time through, the installer complained that some other Cygwin process had locked the readme file
- the installer just looped indefinitely on extracting the README file from alternatives.lst.bz until I killed it
- The only .bz file in C:\cygwin\etc\setup with today’s date was alternatives.lst.bz.
Here’s what the log file recorded, for several thousand lines:
2009/05/04 11:01:23 io_stream_cygfile:
fopen(/etc/alternatives/README) failed 13 Permission denied
2009/05/04 11:01:23 Failed to open
cygfile:///etc/alternatives/README for writing.
I renamed the file to alternatives.lst.bz.bak , then reran setup.exe to successfully upgrade Cygwin.
Now I suppose I should log a bug report…
May 4th, 2009 — Computers
If the apropos command in Cygwin doesn’t find anything expected, run /usr/sbin/makewhatis from your Cygwin bash prompt to rebuild the whatis database.
Thanks to Mike and Igor for their tips.
May 1st, 2009 — Computers
If like me your Windows %path% looks something like this:
PATH=c:rubybin;C:Perlsitebin;C:Perlbin;C:Oracle
OraHome817bin;C:oracleproduct10.2.0gpdbin;C:Program
FilesOraclejre1.1.7bin;C:Python26;C:Python26scripts;C:
Python26Libidlelib;C:cygwinbin;C:Program FilesWindows
Resource KitsTools;C:WINDOWSsystem32;C:WINDOWS;C:WINDOWS
Downloaded ProgramFiles;C:Program FilesIBMDirectorbin;C:
Program FilesDiskeeper CorporationDiskeeper;c:Program
FilesMicrosoft SQL Server90Toolsbinn;C:Program Files
Rationalcommon;c:scripts;C:Program FilesjEdit;C:Program
FilesQuickTimeQTSystem;C:Program FilesTortoiseSVNbin;C:
ipdsdevaxis2axis2c-rel-1.3.0lib;C:Program FilesJava
jdk1.5.0_16bin;C:jruby-1.2.0bin
Then save this to “road.bat” somewhere on your path:
@echo off
rem source: http://www.perlmonks.org/?node_id=757655
for %%i in ("%path:;=" "%") do @echo %%i
When you run C:\>road all those paths are nicely split and one-lined:
C:>road
"c:rubybin"
"C:Perlsitebin"
"C:Perlbin"
"C:OracleOraHome817bin"
"C:oracleproduct10.2.0gpdbin"
...
and you can do cool things like C:\>road | grep -i Perl to find out where Perl is hiding.
To paraphrase the (brilliant) author VinsWorldcom, this one-liner
wraps the %PATH% ENV var in double quotes and then replaces all the semicolon separators with a double-quote, space, double quote. This effectively puts double quotes around all the paths (so spaces won’t give any troubles) then use the for loop to list each newly double-quoted string.
April 29th, 2009 — Computers
Very textmate-y: IR_Black