I wrote a simple PHP shell script which parses files and outputs certain element.
It generates lots of output. In different (bash) colors, green for OK, yellow for warnings, red for errors, etc.
During development I want to filter some lines out. For example all lines that contains red text.
Can I use a grep
(or other) command for this?
I have no idea what your input looks like, but as a proof of concept you can filter any lines in ls
output that use green colour:
ls --color=always | grep '^[\[01;32m'
The lookup table for other colours can be found here: http://en.wikipedia.org/wiki/ANSI_escape_code#Colors
Hint: In case you didn't know, the ^[
part above should be entered like Ctrl-VEsc (or indeed Ctrl-VCtrl-[ on most terminals).
I'm sure there will be some option to grep to make it understand \x1B
instead, but I haven't found it
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With