tags:

views:

62

answers:

2

This expression seems to work:

gci . | % { gc $_}

This also seem to work as well (I suspect it is a little slower):

gci . | Select-String . 

Is there a better way of writing a expression to dump all lines from all files out in a directory?

Thanks

+2  A: 

Well you don't want to throw directories at Get-Content. Try this to filter out dirs:

Get-ChildItem | Where {!$_.PSIsContainer} | Get-Content

or using aliases:

gci | ?{!$_.PSIsContainer} | gc

Also note that Get-Content takes the filename as pipeline input so you don't need the Foreach-Object cmdlet. You can pipe directly to Get-Content.

Keith Hill
good point.. I think you answered my question I can just use gci | gc instead of the | % {$_} construct which seemed a bit cumbersome thanks
JasonHorner
I take it that the dir you're listing contains no directories? If not then `gci | gc` will work just fine.
Keith Hill
A: 

Won't this one do?

gc * -ea SilentlyContinue
hoge
I generally like to avoid errors (even though you can suppress them with `-ea 0`). However, if there are no dirs then `gc *` is the way to go.
Keith Hill