Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place! |
Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
|
08-09-2005, 12:18 AM
|
#1
|
LQ Newbie
Registered: Oct 2004
Posts: 21
Rep:
|
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
|
|
|
08-09-2005, 03:53 AM
|
#2
|
Senior Member
Registered: Sep 2003
Location: Egypt
Distribution: Arch
Posts: 1,528
Rep:
|
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 , .........
|
|
|
08-09-2005, 08:09 AM
|
#3
|
LQ Newbie
Registered: Oct 2004
Posts: 21
Original Poster
Rep:
|
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.
|
|
|
08-09-2005, 06:09 PM
|
#4
|
Member
Registered: Sep 2004
Location: NorCal
Distribution: slackware 10.1 comfy, Solaris10 learning
Posts: 232
Rep:
|
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 This will highlight 'schmoopsie' everywhere in the text. You can go from one highlight to another by pressing N key.
I am pretty sure this is what you remember doing.
Last edited by frankie_DJ; 08-09-2005 at 06:19 PM.
|
|
|
08-09-2005, 11:56 PM
|
#5
|
LQ Newbie
Registered: Oct 2004
Posts: 21
Original Poster
Rep:
|
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.
|
|
|
08-10-2005, 01:44 AM
|
#6
|
Member
Registered: Apr 2004
Distribution: Gentoo
Posts: 65
Rep:
|
I cant figure out what you need, but check out this command, it may help
echo "\033[32m hi"
|
|
|
08-10-2005, 09:11 AM
|
#7
|
LQ Newbie
Registered: Oct 2004
Posts: 21
Original Poster
Rep:
|
this comand is a normal echo. It does not do ANYTHING.
i'll repeat you - I don't know what you mean.
|
|
|
08-10-2005, 10:20 AM
|
#8
|
Member
Registered: Sep 2004
Location: NorCal
Distribution: slackware 10.1 comfy, Solaris10 learning
Posts: 232
Rep:
|
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'`
you just stored your escape sequence into the variable schmoopsie. Now you can use it to change the color of text:
Code:
echo "$schmoopsie[1;33m whass up yo"
You can do other things to:
Code:
echo "$schmoopsie[5m$schmoopsie[1;33mLook at me I am blinking"
Now I guess you can figure out what to do with it. You might wanna alias grep or something to do stuff like that for ya. I can't really help you more cause I don't understand what you need.
Oh yeah, and a little more patience and occasional 'Thank you' wouldn't hurt either.
Last edited by frankie_DJ; 08-10-2005 at 10:21 AM.
|
|
|
08-10-2005, 10:43 AM
|
#9
|
LQ Newbie
Registered: Oct 2004
Posts: 21
Original Poster
Rep:
|
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...
Last edited by tommmmmm; 08-10-2005 at 10:55 AM.
|
|
|
08-10-2005, 01:33 PM
|
#10
|
Member
Registered: Sep 2004
Location: NorCal
Distribution: slackware 10.1 comfy, Solaris10 learning
Posts: 232
Rep:
|
No problem. I don't exactly understand why it doesn't work Andy's way either. Maybe someone else can elaborate on that.
|
|
|
08-10-2005, 02:30 PM
|
#11
|
Member
Registered: Apr 2004
Distribution: Gentoo
Posts: 65
Rep:
|
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 04:07 PM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|