highlighting text in the console
I want to view the file, but i want to distinguish some lines of the file. I want to highlight them in some kind/ change their color. You know what i mean.
I did linuxgoogle searches, asked on jabber linux channel and did aprpopos highlight but nothing found. I also searched this forumn. ps: don't tell me that it's impossible, it's possible, i did such thing with turbo pascal under the linux console |
what editor have you tried ?
and whats the file type ? because there are alot of editors that support syntax highlighting like vim , emacs , kwrite , gedit , ......... |
no.................. not editors. ABSOLUTELY NOT.
i want to do smth like "cat file" but lies that match "grep expression" should be distinguished by another color. So saying once more, i want to "cat file" the whoooooole file but i want to distinguish some lines, some particular lines (changing their colors) that match the grep expression. that's all. |
You can use some pager, like 'less' or 'more' or 'pg' to view the file. Once you open it (i.e. with 'less file_name'), search for pattern "schmoopsie" by typing
Code:
/schmoopsie I am pretty sure this is what you remember doing. |
I already knew that trick. It enables me to do some basic regexp.
But what if i want to use awk or extended regexp? I also ment ( and wrote it above ) that i want to change the color of the lines. I have already read tput and terminfo manuals and i can do any bolding/blinking and highlighting. output of ls command is colorful. I would like to achieve similar effect. |
I cant figure out what you need, but check out this command, it may help
echo "\033[32m hi" |
this comand is a normal echo. It does not do ANYTHING.
i'll repeat you - I don't know what you mean. |
You will have to do a better job explaining us what you need if you want us to help.
We have given you couple of solutions already and neither of them satisfies you. Andy was trying to show you that you can change color of things that you want printed on the screen by using nonprinting characther \033 as escape sequence. Do this Code:
schmoopsie=`echo X|tr X '\033'` Code:
echo "$schmoopsie[1;33m whass up yo" Code:
echo "$schmoopsie[5m$schmoopsie[1;33mLook at me I am blinking" Oh yeah, and a little more patience and occasional 'Thank you' wouldn't hurt either. |
you example works perfect ! Thanks very much
I don't know why simple echo <smth smth> didn't work, but your way of doing things works for me. thank you. http://www.tldp.org/LDP/abs/html/col....html#AEN15210 btw. you could have posted it at the beginning... :tisk: :tisk: |
No problem. I don't exactly understand why it doesn't work Andy's way either. Maybe someone else can elaborate on that.
|
Hmm.. It seems to only work as an echo when useing a certain shell, Zsh (my default), tcsh, both seem to work, while sh, csh, and bash dont.
|
All times are GMT -5. The time now is 08:08 AM. |