Get-Content

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

上一篇:爬虫系列:存储 CSV 文件


下一篇:Jmeter常用逻辑控制器、CSV Data Set Config参数化