powershell - Show the previous and after N lines each for the matched lines? -
the following command show lines match pattern.
cat file.txt | select-string -pattern "..." how show previous , after 3 lines each matched lines? (like -c3 parameter of grep.) possible print out line number?
btw, command slower comparing grep?
specify filename in -path parameter of select-string, , use -context switch specify number of lines before , after include.
select-string -path file.txt -pattern "..." -context 1,3 the file name , line number included in output
Comments
Post a Comment