Giter Club home page Giter Club logo

get-contentfast's Introduction

Get-ContentFast

Fast alternative to Get-Content ####SYNOPSIS Fast alternative to Get-Content ####DESCRIPTION Get-Content is a slow, but powerful cmdlet. Get-ContentFast is a faster alternative with much of the same functionality. Get-ContentFast is limited to only reading text files.

####PARAMETER Path Specify the path to the file you want to read. Pipeline or array input is accepted.

####PARAMETER FullName Pipe the file name for the file you want to read from Get-ChildItem or Get-ItemProperty

####PARAMETER Raw Ignores newline characters and returns the entire contents of a file in one string. By default, the contents of a file is returned as a array of strings that is delimited by the newline character.

####PARAMETER TotalCount Gets the specified number of lines from the beginning of a file. Default is all lines.

####PARAMETER Tail Gets the specified number of lines from the end of a file.

####INPUTS [String] [System.IO.FileInfo] ####OUTPUTS [String] [String[]] ####EXAMPLE Get-ContentFast -Path .\test.txt

Read the file test.txt

####EXAMPLE Get-ContentFast -Path ".\test.txt",".\test2.txt"

Read both files

####EXAMPLE Get-ContentFast -Path .\test.txt -Raw

Read the entire file and output a single string

####EXAMPLE ".\Test.txt" | Get-ContentFast -Tail 4

Read the Test.txt file and only output the last 4 lines.

####EXAMPLE Get-ChildItem Test.txt | Get-ContentFast -TotalCount 5

Read the Test.txt file and ouput only the first 5 lines

####EXAMPLE Get-ChildItem *.txt | Get-ContentFast -TotalCount 4 -Tail 2

Read all text files in the current directory and output the first 4 lines and the last 2 lines

get-contentfast's People

Contributors

martin9700 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

get-contentfast's Issues

get-contentFast is opening files read-write

I'm pretty sure that:
$File = New-Object System.IO.StreamReader -Argument $PathName
opens the file read-write, which will fail if another process has the file open, not allowing writing.

This should open the file readonly as long as reading is allowed by the process that has the file open:
$fs = [IO.File]::Open($PathName, [IO.FileMode]::Open, [IO.FileAccess]::Read, [IO.FileShare]::ReadWrite)
$File = New-Object System.IO.StreamReader -Argument $fs

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.