LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
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


Reply
  Search this Thread
Old 08-09-2005, 12:18 AM   #1
tommmmmm
LQ Newbie
 
Registered: Oct 2004
Posts: 21

Rep: Reputation: 15
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
 
Old 08-09-2005, 03:53 AM   #2
heema
Senior Member
 
Registered: Sep 2003
Location: Egypt
Distribution: Arch
Posts: 1,528

Rep: Reputation: 47
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 , .........
 
Old 08-09-2005, 08:09 AM   #3
tommmmmm
LQ Newbie
 
Registered: Oct 2004
Posts: 21

Original Poster
Rep: Reputation: 15
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.
 
Old 08-09-2005, 06:09 PM   #4
frankie_DJ
Member
 
Registered: Sep 2004
Location: NorCal
Distribution: slackware 10.1 comfy, Solaris10 learning
Posts: 232

Rep: Reputation: 32
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.
 
Old 08-09-2005, 11:56 PM   #5
tommmmmm
LQ Newbie
 
Registered: Oct 2004
Posts: 21

Original Poster
Rep: Reputation: 15
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.
 
Old 08-10-2005, 01:44 AM   #6
andy753421
Member
 
Registered: Apr 2004
Distribution: Gentoo
Posts: 65

Rep: Reputation: 15
I cant figure out what you need, but check out this command, it may help

echo "\033[32m hi"
 
Old 08-10-2005, 09:11 AM   #7
tommmmmm
LQ Newbie
 
Registered: Oct 2004
Posts: 21

Original Poster
Rep: Reputation: 15
this comand is a normal echo. It does not do ANYTHING.

i'll repeat you - I don't know what you mean.
 
Old 08-10-2005, 10:20 AM   #8
frankie_DJ
Member
 
Registered: Sep 2004
Location: NorCal
Distribution: slackware 10.1 comfy, Solaris10 learning
Posts: 232

Rep: Reputation: 32
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.
 
Old 08-10-2005, 10:43 AM   #9
tommmmmm
LQ Newbie
 
Registered: Oct 2004
Posts: 21

Original Poster
Rep: Reputation: 15
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.
 
Old 08-10-2005, 01:33 PM   #10
frankie_DJ
Member
 
Registered: Sep 2004
Location: NorCal
Distribution: slackware 10.1 comfy, Solaris10 learning
Posts: 232

Rep: Reputation: 32
No problem. I don't exactly understand why it doesn't work Andy's way either. Maybe someone else can elaborate on that.
 
Old 08-10-2005, 02:30 PM   #11
andy753421
Member
 
Registered: Apr 2004
Distribution: Gentoo
Posts: 65

Rep: Reputation: 15
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.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
How do I see all text in console? fannymites Linux - General 2 04-15-2005 06:01 PM
Highlighting text in Xterm...difference between RedHat and Suse guychambertain Linux - General 3 10-25-2004 07:28 PM
Html highlighting? Attach text to picture? chii-chan Linux - General 3 10-08-2004 01:52 AM
Console text gamehack Slackware 6 09-25-2004 04:00 AM
Getting rid of highlighting in a vi editor text file. Dee62 Linux - Newbie 6 03-11-2004 02:55 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 04:07 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration