作者:网络 软件教程库 2020-05-13
19 down vote favorite
i need to save the result of a grep command into a file, but i also want the output file to be formatted and keep the colors just like in the terminal.
is there a way to do that maybe make grep save to a some kind of markup language if it is not possible, is there another tool that can accomplish this task
i am trying to make the search keyword stand out in the output file, exactly like it does in the terminal.
5 down vote
depending on what you‘re wanting to do with the output file, it‘s possible to add colors to normal text file, because the colors simply come from some special characters. grep seems to not want to print them when you redirect it to a file, so you need to force it to:
now, when you print the file to the console it will be printed with the colors, because bash interprets those characters as "use this color".
however, if you open it in an editor like
the output looks right when i print it using
so if you‘re wanting to use an editor this probably isn‘t what you want.
saving output of a grep into a file with colors
dzy loves topological sorting time limit: 4000/2000 ms (jav ...
使用单条sql来查询出awr中的syatem statistics 参考自： how to monitor system ...