Linux - NewbieThis 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.
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.
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
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.
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
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.
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.
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.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.