SPUG: One-liners on Windows via command.com

Aaron W. West tallpeak at hotmail.com
Wed Mar 23 17:56:56 PST 2005

I find that if I'm using CMD.EXE, since I have to use double-quotes around 
my script and avoid double with the quoted string, I use qq() or qq{} (etc) 
instead of "".


It's been said a few times, but I'll say it again.


I've been using it for almost two years now, and can't imagine why I'd ever 
want to learn something as esoteric as 4DOS / 4NT anymore (which I used 
years ago but never bought...), nor many of the weird command-line tools I 
collected over the years, and unix imitations, when it's all compiled for me 
and works so well in the Cygwin environment. I use Cygwin for bash, command 
history, SSH/SCP -- SSH tunneling to get through a firewall (a sort of 
poor-man's VPN...), and I know I'm missing many of the features of a 
full-blown unix environment, but I have all my favorite unix tools at my 

But as someone's later group mail seems to complain, installation on other's 
machines seems a bit problematic. I'd like to see the installation made 
easier to customize. It's too slow to bring up the categories, and needs 
some features to save commonly-used configurations so that you can install 
the same stuff on several machines. I've installed Cygwin on each of four 
machines, twice (different versions), and each time I seem to end up getting 
frustrated with the setup and saying to heck with it, I'm just downloading 
everything and installing it all... Yet, I would be reluctant to ask that 
all my coworkers install 100,000+ files onto their desktops. So I hope 
future versions of setup are a little bit less clunky-feeling... though it's 
difficult for me to see how they can really make it a whole lot easier. 
Maybe some DHTML tree selection in a web browser would work faster... again, 
as long as the package selections can be saved as setup configurations to be 
used later. Also, I wonder if they might consider some sort of 
compressed-loopback-type-filesystem (or "Stacker"-like driver, though I may 
be hesitant to load a filesystem driver just to run Cygwin...), if it's 
possible in Win32 -- on modern 200 gig hard drives, it's not the size of 
files that's the problem, it's the fact that file find and indexer programs 
may try to scan all those files, and the growth of the MFT, both of which 
are affected by the large number of files in a full installation of Cygwin 
with all its packages. It doesn't really bother me on my machines; I 
occasionally run:

find /cygdrive/ > ~/allfiles

..then just use:

grep whatever ~/allfiles

..whenever I want to scan all filenames on my computer. Or the equivalent 
perl command, etc.

When I first saw the subject line, I wondered if someone was starting a 
one-liner contest... well, I seem not to have much in my bash history lately 
that is of general use.

Stripping nuls from some unicode-encoded registry files:

perl -p -i -e 'tr/\0//d' *JQ.reg

Some histogram of word lengths...

perl -le 'while(<>){tr/a-z//cd;$lengths[length]++};for (1..$#lengths){printf 
"%6d words are %2d long\n", $lengths[$_], $_}; for(9..28){$s+=$lengths[$_]}; 
printf "%6d words are 9 to 28 chars long\n", $s' enable1.txt > wordfreq.txt

Even for something that fairly short (eg. 40+ characters), an editor is 
probably a lot easier to use and less error-prone than the command line. 
Also, the editing features of CMD.EXE leave something to be desired, and I 
find myself going nuts when I switch from my familiar cygwin bash shell back 
to brain-dead CMD.EXE partly just because of lack of backward-word (esc-b), 
forward word (esc-f), delete word (escape-d), delete-to-end-of-line (esc-k), 
yank (ctrl-y), repeat (esc-digit), begin-line (ctrl-a), endofline(ctrl-e), 
and other familiar (emacs-mode) command-keys.

----- Original Message ----- 
From: <byoung at speakeasy.net>

One word-- cygwin.

I just run all my Perl programs under bash (and/or XEmacs). I've always just 
accepted that cmd.exe is damaged goods.


More information about the spug-list mailing list