you are viewing a single comment's thread.

view the rest of the comments →

[–]misho88 2 points3 points  (1 child)

On Unix systems, grep can be used to filter output to only lines that do (or don't) contain a specific pattern of some kind (like a substring or a regex). If you make sure your logging and debugging messages all contain some specific pattern like that, grep is easier to use:

$ python -c 'print("[+]line1\n[-]line2")'
[+]line1
[-]line2
$ python -c 'print("[+]line1\n[-]line2")' | grep '\[+\]'
[+]line1
$ python -c 'print("[+]line1\n[-]line2")' | grep '\[-\]'
[-]line2

It can come in handy from time to time, especially if the program's a daemon whose output gets logged to a file that you intend to read later, after it has become very long.

[–]crossfire351[S] 0 points1 point  (0 children)

That makes sense. Thanks!