Re: How do Unix grep, find, sort?

From: Roger Abell (mvpNOSpam_at_asu.edu)
Date: 02/27/05


Date: Sun, 27 Feb 2005 11:25:56 -0700

Unix find is so highly evolved one could actually consider it a
little library of routines invocable on switch. I recall back around
1996 after starting Windows admin after many years in Unix, asking
some MS folks where was the "find" utility. They just said, "find,
we have find" - a total disconnect in meaning which I attempted to
clarify but finally gave up.
You can load the Unix tools, either from third-parties, or look for
Services For Unix (SFU) from MS (they did have a free offer some
time back). That will get you going in the ways you are used to,
with find piped to, with the *greps, etc..
Some of the ability exists with the old commandline syntax, which
is actually a legacy from DOS. If you are like me you will find it
rather arcaine, limited, and systactically ugly.

You may be interested in the next generation command shell MSH,
which is in a somewhat open beta at this time - it is (more than)
something of a hybrid of the best features of most all previous shell
languages in all OSs - at least that is (one of) the objectives. However,
its piping capability is much more powerful as one passses objects
down the pipe . . .
OK, keeping with the initial comment, that find is really a little
library, you will have to do some things by evolving your own
little set of vbs scripts.
In your exampled case you might write a routine the does the
replace in file, pretty much
      getargs -> file, search sting, replace string
      open file, open temp file
      per infile line use replace function
      close files and replace old with new
locate file, calling replace, pretty much
      get handle to folder
      for each file in folder
           test age (based on create, access, or modify timedate)
                invoke the replace routine
      for each folder, recurse if desired
Now, you can design these so that they are
reusable, and you can package them into script
componnets and reference them from a very short
driver vhs that you write as a one-off on need.
You could also inline the replace into one script
and it would be rather short, but then you are in the
ball game of reversioning for the next different need
(something I find myself doing too much).

But that is all down the road from where you are right
now, and you will not find a single library of such script
components that has evolved within the community (which
is how we evolved find, the grep's, lex/yak, etc.)
Right now it is still much a roll your own world, in Windows
although with a lot of code sharing by way of examples and
also of so-and-so's library, etc..

So getting the Interx portion of the SFU loaded may be the
way for you to get immediately productive (not to mention
having vi, etc. available).

However, do go down the road with some script language.
You will find it is extremely powerful in Windows - much
more so than any shell language in Unix - if only because of
the ability to instance just about anything and make use of
its methods.
Oh yea, do check out MSH.

-- 
Roger Abell
Microsoft MVP (Windows  Security)
MCSE (W2k3,W2k,Nt4)  MCDBA
"noleander" <noleander@discussions.microsoft.com> wrote in message
news:55BCEEA9-01A9-4D10-AA5B-E7F1C21095D8@microsoft.com...
> Hi.  I'm new to Windows, after programming for 20 years in Unix.  I'm
willing
> to give Windows a fair shot, but I'm having a heck of a time getting
started.
>  Here is a typical thing I'll need to do:
>
>    *** Find all text files that are less than one month old (under a given
> folder) and within those files replace all occurances of string "xyz" with
> string "abc".
>
> I'm used to the Unix approach, piping commands like grep, find, and ex
> together.
>
> But I've been studying VBScript all day, and I swear I cannot figure out
how
> to do the above task.
>
> My question is:  What is the normal scripting approach in Windows to
> accomplish the task I describe above?  Pointers to sample code would be
much
> appreciated!
>
>   neal
>


Relevant Pages

  • Re: Help from fellow Fortran Users
    ... >> of the UNIX and Linux communities or to the intensity of general desire ... > difference in fklavor between UNIX and Windows. ... of a language useful for writing portable programs. ...
    (comp.lang.fortran)
  • Re: What is the more popular UNIX flavor?
    ... about my experience with Solaris and Cygwin. ... installing packages. ... needing eg tftp you only need to activate on a Unix system. ... probably need installing first on the equivalent Windows system. ...
    (comp.unix.questions)
  • Re: Five Architectural Flaws in Windows Solved In Mac OS X
    ... But it is still an improvement over Unix, wherein *any executable* can be highly privileged and interact with the user. ... The usual security precautions prevent unauthorized people from doing this, but that's true on Windows also. ... I just got thru upgrading the wifes Mac to Tiger and hpfs is the default. ... This is a more advanced design that Unixes have been trying to duplicate by adding thread support. ...
    (comp.sys.mac.advocacy)
  • Re: Linux no threat to Microsoft
    ... originally developed for Unix. ... Windows has't come on any of the machines I've ever purchased. ... Yet over those years Linux Market Share on the desktop has actually ... philosophy of Apple - later adopted by Microsoft. ...
    (comp.os.linux.setup)
  • Re: OS X "Security" myths
    ... >> lot of UNIX systems down to their knees. ... >>> their code, so they concentrate on developing exploits for Windows, ... > It does tell me that there is not much "boast factor" for malware ... Just like the Hackers convention in Las Vegas known as ...
    (comp.sys.mac.advocacy)