Community
    • Login

    Tail with filter

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    2 Posts 2 Posters 62 Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • FranzF
      Franz
      last edited by

      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

      PeterJonesP 1 Reply Last reply Reply Quote 0
      • PeterJonesP
        PeterJones @Franz
        last edited by PeterJones

        @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 into filtered.log in the same directory; when you then open filtered.log in tail-mode, only the text that matches the filter will make it into filtered.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)

        1 Reply Last reply Reply Quote 2
        • First post
          Last post
        The Community of users of the Notepad++ text editor.
        Powered by NodeBB | Contributors