GetContent

Print the first 100 lines of big_file.csv:

Get-Content -First 100 'C:\Users\jason\Desktop\big_file.csv'

Print the last 100 lines of big_file.csv

Get-Content -Last 100 'C:\Users\jason\Desktop\big_file.csv'

Print lines that contain the word "Utah"

Get-Content 'C:\Users\jason\Desktop\big_file.csv' | Select-String "Utah"

Get the first 100 lines of big_file.csv and write them to a new file, sample.csv

Get-Content -First 100 'C:\Users\jason\Desktop\big_file.csv' | Out-File 'C:\Users\jason\Desktop\sample.csv'

Count the number of lines in big_file.csv (3 separate commands)

Note that we tell the PowerShell to count in chunks of 2,000 rows

$count = 0
Get-Content '.\big_file.csv' -ReadCount 2000 | foreach { $Count += \(_.count } \)count

原文地址:https://www.cnblogs.com/yinguo/p/15671425.html