Welcome › Forums › General PowerShell Q&A › How to delete lines after n-th line
I have very basic knowledge about powershell, i still learning. so please don’t get mad if i asking silly question
here is the job i am trying to achieve:
i have multiple text files
inside text there is content lets say
line 1 asdb</p><p>line 2 asdas</p><p>line 3 sfsdsfd</p><p>line 4 sgsf</p><p>line 5 sgfsdf</p><p>line 6 sfsf</p><p>...</p><p>..line 100 sfsdf
i want to remove all line after line 5 and save the text file. will it be possible to do it using powershell?
yes it is. pick the first 5 lines with select -first 5 and then output that to a file.
thank you problem solved 🙂