A pedant that hangs out in the dark corner-cases of the web.

Tuesday, May 07, 2013


Searches files for pattern, displays matches, opens in text editor.
.Parameter Pattern
Specifies the text to find. Type a string or regular expression. 
If you type a string, use the SimpleMatch parameter.
.Parameter Filters
Specifies wildcard filters that files must match one of.
.Parameter Path
Specifies a path to one or more locations. Wildcards are permitted. 
The default location is the current directory (.).
.Parameter Include
Wildcard patterns files must match one of (slower than Filter).
.Parameter Exclude
Wildcard patterns files must not match any of.
.Parameter CaseSensitive
Makes matches case-sensitive. By default, matches are not case-sensitive. 
.Parameter List
Returns only the first match in each input file. 
By default, Select-String returns a MatchInfo object for each match it finds.
.Parameter NotMatch
Finds text that does not match the specified pattern.
.Parameter SimpleMatch
Uses a simple match rather than a regular expression match. 
In a simple match, Select-String searches the input for the text in the Pattern parameter. 
It does not interpret the value of the Pattern parameter as a regular expression statement.
.Parameter NoRecurse
Disables searching subdirectories.
C:\PS> Find-Lines 'using System;' *.cs "$env:USERPROFILE\Documents\Visual Studio*\Projects" -CaseSensitive -List

This command searches all of the .cs files in the Projects directory (or directories) and subdirectories,
displays the first matching line of each file with a match, then opens the file to the correct line in the editor.
# set up splatting
$lsopt = @{Recurse=!$NoRecurse}
if($Path) { $lsopt.Path=$Path }
if($Include) { $lsopt.Include=$Include }
if($Exclude) { $lsopt.Exclude=$Exclude }
$ssopt = @{'Pattern'=$Pattern}
if($CaseSensitive) { $ssopt.CaseSensitive=$true }
if($List) { $ssopt.List=$true }
if($NotMatch) { $ssopt.NotMatch=$true }
if($SimpleMatch) { $ssopt.SimpleMatch=$true }
# the filter parameter is much faster than the include parameter
Select-String -Path ($( if($Filters) { $Filters|% {ls @lsopt -Filter $_} } else { ls @lsopt } ) |
    ? {Test-Path $_.FullName -PathType Leaf}) @ssopt |
  ogv -p -t "Search: '$Pattern' $Filters" |
  % {emeditor $_.Path /l $_.LineNumber} #TODO: customize editor


Anonymous said...

I drop a leave a response each time I like a article
on a site or I have something to contribute to the conversation.
It's caused by the sincerness communicated in the article I looked at. And on this post "Find-Lines.ps1". I was actually excited enough to drop a thought ;) I do have 2 questions for you if it's allright.

Is it simply me or does it look like like a few of the
comments appear as if they are coming from brain dead
people? :-P And, if you are posting at other online social
sites, I'd like to keep up with you. Could you list the complete urls of your social pages like your twitter feed, Facebook page or linkedin profile?

Feel free to visit my blog ... http://wiki.2roues4saisons.org/index.php?title=Utilisateur:CharissaO

Anonymous said...

Hey! Would you mind if I share your blog with my twitter group?
There's a lot of folks that I think would really enjoy your content. Please let me know. Cheers

Also visit my webpage; akribos xxiv watches for women

Anonymous said...

Piece of writing writing is also a excitement, if you
be acquainted with afterward you can write otherwise it is complicated to write.

Stop by my blog: rc hobbies now

Anonymous said...

First off I want to say wonderful blog! I had a quick question in which I'd like to ask if you do not mind. I was interested to know how you center yourself and clear your mind before writing. I've had a difficult time
clearing my mind in getting my ideas out. I truly do take pleasure in writing however it just
seems like the first 10 to 15 minutes are generally wasted simply just trying to figure
out how to begin. Any ideas or hints? Many thanks!

My blog post; http://fl.alphastudio.cz/wiki/index.php?title=uživatel:suzanna27

Anonymous said...

You will need the best of the best, sounds and samples
that is, and you will also need to continually expand upon your
sound library. We constraint prepare any Mac, finance your Apple Computer or replace virtually chunk Apple part or component reputation almost any apple Mac
laptop and desktop pull London, UK. From left to right along the front edge of the Mac - Book
Pro are.

Feel free to surf to my homepage :: mac book pro

Anonymous said...

Fantaѕtіc beаt ! Ӏ wοuld
like to apprenticе whilе you amеnd your ωebsite, how
can і subscribe fоr a blоg site? Thе aсcount aideԁ me a acceptable dеаl.
I had bеen tiny bit аcquainted οf this уour brοаdcаst offerеd bright сleaг iԁеа

my web page die Abnehm Lösung

Anonymous said...

you're really a excellent webmaster. The site loading pace is incredible. It kind of feels that you'гe ԁoing anу unique trick.
Αlso, The contents are masterpiece. you haѵe performеd a fantaѕtic job in thiѕ

my webpage ... linked web-site

Anonymous said...

Nіce blog! Is your thеme custom maԁe οг did you download it from somewhere?
А design lіkе уοurs ωіth
a few simple adjustements ωould really
make my blog shine. Please let me know whеre you
got уouг design. Appreciate it

my homepаge - hemorrhoids

Anonymous said...

Its like you read my mind! You appear to know so much about this,
like you wrote the book in it or something. I think
that you can do with a few pics to drive the message home
a little bit, but instead of that, this is excellent blog.

A great read. I'll certainly be back.

Review my site :: relic watches for women

Anonymous said...

I сouldn't refrain from commenting. Well written!

my page; Mittel gegen Haarausfall

Anonymous said...

Yard - check for ant hills or evidence of moles and other insects that can damage your lawn.
The Easy Clip Fan is a must and definitely an essential for incoming
college freshmen. You paid a lot of money for the compressor to cool these coils, right.

Have a look at my blog ... nest thermostat

Anonymous said...

The Canon EOS 5D Mark II is $2,499 for body only or $3,299 with a 24'105mm lens. On the other hand when you add a vertical grip and a second battery to selected camera design the cameras all of a sudden complete speedier. But there are only a few that put out top quality cameras.

Feel free to visit my page - canon 6d

Anonymous said...

For the better experience of audio-listening, HTC Desire C provides you with
Beats Audio. Music player, P503 supports a variety of media formats.
It can also be used to quickly search Google or Wikipedia.

Feel free to visit my site; samsung s4

Anonymous said...

Look at the user remarks in places like Amazon and B&H photo.
Some as well as components of the Nikon D700 are these:.
Compared to the standard prices of camcorders, a
DSLR holds its own.

Also visit my weblog; canon mark 5d iii

Anonymous said...

Woω, wondeгful blog laуout! How long haѵe уou
been blogging for? you maκe blogging look eаѕy.

The оvеrall look of уour web ѕite іѕ greаt, аѕ ωell
аѕ the соntent!

my websіtе; Kreisrunder Haarausfall

Anonymous said...

Nісe ρost. I was checκіng conѕtantly thiѕ
blog аnd I'm impressed! Extremely helpful information specifically the last part :) I care for such info a lot. I was seeking this certain info for a long time. Thank you and best of luck.

Review my web-site click The next Website Page

Anonymous said...

Good way of explaining, and goοd aгtіcle
to obtain datа regarding mу preѕentatіоn fοcus, ωhich i am going tο deliver іn

Check оut my site just click the up coming site

Anonymous said...

Dexter Mo Gym and former real estate broker, Katie Saxton, revolutionized the beauty and nail aficionado may
question the cost and time in using Custom Nail Solutions was born.
We must analyze and fully integrate ongoing operating costs
into whatever facilities proposals are ultimately made.

my page; Zach