Group:  English: General ยป microsoft.public.windows.powershell
Thread: Considering moving from bash...

DotNetBag
.NET Development Newsgroups

HTVi
TV Discussion Newsgroups

Our Hot Pick: Rising Antivirus 2006 - Certified by TUV & Checkmark! Get 10% discount by entering this coupon code: ONDISCOUNT10
Rising Antivirus 2006

Considering moving from bash...
Larry <lportx[ at ]gmail.com> 13.07.2007 12:44:51
I develop .Net apps on Windows but come from the Linux world and have
installed cygwin on my machine and am too lazy to learn Powershell
(let's be brutally honest).

That said, if someone could lemme know what the Powershell equivalent
of the following commands I would switch over and begin using it. But
I am under a major push right now and having to look through the
documentation is daunting.

1) find .
2) find . -name "*.cs"
3) grep -i mytext `find . -name "*.sql"`
4) less (with searching via "/" and tail mode (Waiting for Data...)
via "F"

Thanks, sorry to be a newb.

Re: Considering moving from bash...
Hal Rottenberg <halr9000[ at ]gmail.com> 13.07.2007 13:35:17
On Jul 13, 8:44 am, Larry <lpo...[ at ]gmail.com> wrote:
[Quoted Text]
> That said, if someone could lemme know what the Powershell equivalent
> of the following commands
>
> 1) find .

get-childitem, aliases: ls, dir

One thing you'll have to learn is that PSH is object-oriented. So it
won't make sense at first that while "duh, of course ls returns a list
of files", it's not, it's returning an array of file objects which you
can actually do stuff with like send them through a pipeline.

> 2) find . -name "*.cs"

ls *.cs -r

I'm assuming here that you would want to recurse like find does. Like
anything in Windows, the current working directory is assumed. You
could do "ls . *.cs -r" if it would make you feel better. :)

> 3) grep -i mytext `find . -name "*.sql"`

new-alias grep select-string
ls *.sql -r | grep mytext

I could probably flip it around to make it more grammatically similar
to bash...hmm...

grep mytext -inputobject $(ls *.sql -r)

No, didn't work. Needs work. :)

> 4) less (with searching via "/" and tail mode (Waiting for Data...)
> via "F"

Grab and install the Powershell Community Extensions (PSCX), less is
included. I don't recall the answer to the 'tail -f' question but it
was asked here recently, try searching the newsgroup.

Re: Considering moving from bash...
Hal Rottenberg <halr9000[ at ]gmail.com> 13.07.2007 13:43:27
Awwww man I had a really good reply which got lost. Grrrrrrr... ok,
here we go again.

On Jul 13, 8:44 am, Larry <lpo...[ at ]gmail.com> wrote:
[Quoted Text]
> That said, if someone could lemme know what the Powershell equivalent
> of the following commands I would switch over and begin using it.
>
> 1) find .

get-childitem, aliases: dir, ls

The -r (or -recurse) will give you find behavior. The thing you have
to get used to though is that this isn't returning a list of files
like ls. Powershell is object-oriented. Get-childitem returns an
array of objects which can be sent down the pipeline.

> 2) find . -name "*.cs"

ls *.cs -r

The current working directory is assumed. You could type "ls . *.cs -
r" if it would make you feel better. :)

> 3) grep -i mytext `find . -name "*.sql"`

new-alias grep select-string
ls *.sql -r | grep mytext

See how the pipeline works here? This is one of the core benefits of
Powershell.

> 4) less (with searching via "/" and tail mode (Waiting for Data...)
> via "F"

Find and install the Powershell Community Extensions (PSCX), it
includes less. I don't remember the answer to 'tail -f' but it's been
asked before. Try searching the newsgroups.

Re: Considering moving from bash...
Larry <lportx[ at ]gmail.com> 13.07.2007 13:52:01
Thank you Hal...I will let you know how it goes...This should be
enought to bootstrap myself and get used to the system.

On Jul 13, 9:43 am, Hal Rottenberg <halr9...[ at ]gmail.com> wrote:
[Quoted Text]
> Awwww man I had a really good reply which got lost. Grrrrrrr... ok,
> here we go again.
>
> On Jul 13, 8:44 am, Larry <lpo...[ at ]gmail.com> wrote:
>
> > That said, if someone could lemme know what the Powershell equivalent
> > of the following commands I would switch over and begin using it.
>
> > 1) find .
>
> get-childitem, aliases: dir, ls
>
> The -r (or -recurse) will give you find behavior. The thing you have
> to get used to though is that this isn't returning a list of files
> like ls. Powershell is object-oriented. Get-childitem returns an
> array of objects which can be sent down the pipeline.
>
> > 2) find . -name "*.cs"
>
> ls *.cs -r
>
> The current working directory is assumed. You could type "ls . *.cs -
> r" if it would make you feel better. :)
>
> > 3) grep -i mytext `find . -name "*.sql"`
>
> new-alias grep select-string
> ls *.sql -r | grep mytext
>
> See how the pipeline works here? This is one of the core benefits of
> Powershell.
>
> > 4) less (with searching via "/" and tail mode (Waiting for Data...)
> > via "F"
>
> Find and install the Powershell Community Extensions (PSCX), it
> includes less. I don't remember the answer to 'tail -f' but it's been
> asked before. Try searching the newsgroups.


Re: Considering moving from bash...
"Keith Hill" <r_keith_hill[ at ]mailhot.moc.no_spam_I> 13.07.2007 14:22:01
"Hal Rottenberg" <halr9000[ at ]gmail.com> wrote in message
news:1184334207.080643.92440[ at ]22g2000hsm.googlegroups.com...
[Quoted Text]
> Awwww man I had a really good reply which got lost. Grrrrrrr... ok,
> here we go again.
> Find and install the Powershell Community Extensions (PSCX), it
> includes less. I don't remember the answer to 'tail -f' but it's been
> asked before. Try searching the newsgroups.

The get-content cmdlet has a -wait parameter that makes get-content behave
like tail -f.

--
Keith

Re: Considering moving from bash...
"Flowering Weeds" <floweringnoweedsno[ at ]hotmail.com> 13.07.2007 22:04:56

"Larry"

[Quoted Text]
> 1) find .
> 2) find . -name "*.cs"
> 3) grep -i mytext `find . -name "*.sql"`
> 4) less (with searching via "/" and tail mode (Waiting for Data...)
> via "F"
>

The above are other processes so:

Perhaps Microsoft's Log Parser 2.2

Perhaps Microsoft's List

Perhaps Microsoft's Tail.


Home | Search | Terms | Imprint | Contact
Newsgroups Reader - provided by WiredBox.Net