SOLVED

How to Read Certain line in Powershell

Brass Contributor

How can I read line number 10  from a text file ?1

2 Replies
best response confirmed by niazstinu (Brass Contributor)
Solution

@niazstinu 

There are multiple way

The easiest is Load the file and select the line you need as its an array

$x=Get-content C:\MyFile.txt

$x[9]

Or you can use this way

$x | select -First 1 -Skip 9

@farismalaeb 

ys, exactly what i was looking for.

thanks

 

1 best response

Accepted Solutions
best response confirmed by niazstinu (Brass Contributor)
Solution

@niazstinu 

There are multiple way

The easiest is Load the file and select the line you need as its an array

$x=Get-content C:\MyFile.txt

$x[9]

Or you can use this way

$x | select -First 1 -Skip 9

View solution in original post