Tail with filter
-
Hi,
is there an option to use tail with a filter? So only lines with a specific text will appear in the result.
BR
Franz -
@Franz ,
Natively, no. Notepad++ doesn’t have a “filter” feature that just hides text without deleting it.
There might be some plugins that do a “filter”-like feature, but I don’t know which they are, and it would be doubtful if they’d work correctly with the Monitor (tail -f) feature of Notepad++. If someone else knows of a way, they can chime in.
As a workaround: assuming you have the
logfile.log
open as the current file (doesn’t need to be in “tail” mode, but it can be): Run > Run…powershell -command "Get-Date -Format 'MM/dd/yyyy' >> '$(CURRENT_DIRECTORY)\filtered.log' ; Get-Content -Path '$(FULL_CURRENT_PATH)' -Wait | Select-String -pattern '^[AEOIU].*$' >> '$(CURRENT_DIRECTORY)\filtered.log';"
and then File > Open
filtered.log
, and set Monitor (tail -f).This example filters your original
logfile.log
for any line in that starts with a vowel, and pipes it intofiltered.log
in the same directory; when you then openfiltered.log
in tail-mode, only the text that matches the filter will make it intofiltered.log
, which you are watching as it goes, so it gives you the basic effect, even though Notpead++ doesn’t do it natively.If you want something other than “starts with a vowel”, change the
'^[AEOIU].*$'
from the command I gave to a valid powershell regular expression (make sure to keep it wrapped in single quotes, like the example regex was). (In this forum, we’re good at Notepad++ regular expressions; but powershell regex are not our area of expertise, so, if you need help with the powershell regex aspect, this forum probably isn’t the best place to ask)