Reputation: 123
I have a large file (3mb) and I need to extract 1000 characters before and after a found pattern.
I am currently using
Select-String -Pattern "695614"
in the Power Shell but this is printing out the entire file, there are not line breaks in this file.
Any idea?
Upvotes: 0
Views: 45
Reputation: 68341
I think this should handle that;
(get-content c:\somedir\somefile.txt -raw) -replace '.*(.{1000}695614.{1000}).*','$1'
Upvotes: 2