Sign up ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I would like to have a live preview of a filtered plain text lines. It is important that multiple filters need to be applied either exclusively or inclusively (similar to the filters in process monitor). After filtering is ready, I would like to be able to export the result.

I could achieve similar with grep "filter1\|filter2\|filter3 but some of my greps are buggy and it is hard to maintain this kind of filters there are plenty filters. Live preview is not easily achieved either, because | head is only a few lines and with | less where I can do text search, I'm not sure if I can save the result. (Also it's a bit inconvenient with pipeline, even if I like command line.)

For a different user experience, I could use something more visual (although prefer minimal).

share|improve this question

2 Answers 2

Look what I made for you, cute little naxa :)

running on /proc/cpuinfo

The above is the result of running python3 /proc/cpuinfo with the filters you see in the screenshot above.

Reading from stdin would be nice, but it's hard because Qt does not seem to support it. I guess you could do it in plain Python, run the Qt app in another thread, and have Qt listen on a socket (and feed it from the Python main thread)... Too much work for a tiny improvement. I guess you already have your data if you want to try live filters.

On Ubuntu, you can install python3-pyqt4 to get PyQt (which is needed).

from PyQt4 import Qt
import sys
import fileinput
import re

class LiveLineFilterApplication(Qt.QApplication):

    def __init__(self, args):
        Qt.QApplication.__init__(self, args)

        self.unfilteredlines = [x for x in fileinput.input()]



    def addWidgets(self):
        self.w = Qt.QWidget()
        self.layout = Qt.QVBoxLayout(self.w)

        self.input = Qt.QTextEdit(".*", None)

        self.textedit = Qt.QTextEdit("pending", None)


    def slotRefilter(self):
        filters = self.input.toPlainText().strip()
        matches = self.unfilteredlines
        for filt in filters.split("\n"):
          if filt == "": continue
          r = re.compile(filt)
          matches = [x for x in matches if]

if __name__ == "__main__":
    app = LiveLineFilterApplication(sys.argv)


share|improve this answer
wow thanks! do we know each other? ;P – n611x007 Jun 10 '13 at 18:08
@naxa: no, i was just trying to freak you out :P. Tell me if the program works for you. – Janus Troelsen Jun 10 '13 at 18:17

Software requests are off topic here. However, as a workaround, you could use grep's -f flag:

   -f FILE, --file=FILE
          Obtain patterns from FILE, one per line.   The
          empty   file   contains   zero  patterns,  and
          therefore matches nothing.  (-f  is  specified
          by POSIX.)
share|improve this answer
didn't know it's off-topic. there is a tag software-rec. => ??? btw thanks for noting! – n611x007 Jun 9 '13 at 14:15
@naxa Yes, there's a tag but tags can be created by anyone, see here, this falls under "product recommendation". – terdon Jun 9 '13 at 14:17
@terdon: No, not anyone. You need 300 rep. – Janus Troelsen Jun 9 '13 at 14:18
@naxa it's on topic for questions about a particular problem (read: anything but "What program can do this?"). From the software-rec tag: Important: It's often better to ask for a real problem instead of a software to solve it. So in this case, it would have been better to simply ask how it's possible to combine regular expressions, or inquire as to how the grep tool could be used to stack filters (the general ideology of that still falls under the general UNIX philosophy). – Breakthrough Jun 9 '13 at 14:38
I see, thank you very much! I seek user experience here, not mere 'functionality', since it would add meaningful value for me. (Thinking loudly : this should be valid right, since otherwise I would only need cat and gcc, not even grep). I better word it torwards the user experience then. – n611x007 Jun 9 '13 at 14:43

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.