LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
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 05-26-2022, 08:58 AM   #16
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,792

Rep: Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306

By default coloring does not work when you pipe grep output to another command.
You need to specify --color=always to make it work.

Otherwise would be nice to post full commands, your posts are almost completely useless.
 
Old 05-26-2022, 10:01 AM   #17
Faki
Member
 
Registered: Oct 2021
Posts: 574

Original Poster
Rep: Reputation: Disabled
Code:
echo $GREP_COLORS
gives an empty line. So there is something going on in my .bashrc settings.

Last edited by Faki; 05-26-2022 at 10:02 AM.
 
Old 05-26-2022, 10:05 AM   #18
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,792

Rep: Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306
please try
Code:
echo $GREP_COLORS | od -xc
 
Old 05-26-2022, 10:46 AM   #19
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,679

Rep: Reputation: 5892Reputation: 5892Reputation: 5892Reputation: 5892Reputation: 5892Reputation: 5892Reputation: 5892Reputation: 5892Reputation: 5892Reputation: 5892Reputation: 5892
Did you logout and log back in? That is the easiest way to reload everything.
 
Old 05-26-2022, 12:24 PM   #20
teckk
LQ Guru
 
Registered: Oct 2004
Distribution: Arch
Posts: 5,136
Blog Entries: 6

Rep: Reputation: 1826Reputation: 1826Reputation: 1826Reputation: 1826Reputation: 1826Reputation: 1826Reputation: 1826Reputation: 1826Reputation: 1826Reputation: 1826Reputation: 1826
Where did you get the idea for 46?

Code:
col0=$(tput setaf 0) #0 black
col1=$(tput setaf 1) #1 red
col2=$(tput setaf 2) #2 green
col3=$(tput setaf 3) #3 yellow
col4=$(tput setaf 4) #4 blue
col5=$(tput setaf 5) #5 magenta
col6=$(tput setaf 6) #6 cyan
col7=$(tput setaf 7) #7 white
clr=$(tput sgr0) #clear

for i in $col{0..7}; do
    echo ""$i"Hello world"$clr""
done
This does not give a color.
Code:
echo ""$(tput setaf 46)"Hello world"$clr""

Last edited by teckk; 05-26-2022 at 12:26 PM.
 
Old 05-26-2022, 12:34 PM   #21
teckk
LQ Guru
 
Registered: Oct 2004
Distribution: Arch
Posts: 5,136
Blog Entries: 6

Rep: Reputation: 1826Reputation: 1826Reputation: 1826Reputation: 1826Reputation: 1826Reputation: 1826Reputation: 1826Reputation: 1826Reputation: 1826Reputation: 1826Reputation: 1826
Also
Code:
<<'------Bash Block Remark------'
Black        0;30     Dark Gray     1;30
Blue         0;34     Light Blue    1;34
Green        0;32     Light Green   1;32
Cyan         0;36     Light Cyan    1;36
Red          0;31     Light Red     1;31
Purple       0;35     Light Purple  1;35
Brown/Orange 0;33     Yellow        1;33
Light Gray   0;37     White         1;37
------Bash Block Remark------

for i in {30..37}; do
    echo -e "\e[0;"$i"mHello world"
done
 
  


Reply

Tags
bash, colour, grep



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
matching colour escape codes Faki Linux - Newbie 10 05-04-2022 03:25 PM
Find/grep command to find matching files, print filename, then print matching content stefanlasiewski Programming 9 06-30-2016 05:30 PM
Creating an alias in ksh that uses grep and includes 'grep -v grep' doug248 Linux - Newbie 2 08-05-2012 02:07 PM
[SOLVED] Matching two tables of non-matching sizes astroumut Programming 3 03-03-2011 07:05 AM
Perl Script needed to be reversed to output matching, not non-matching 0bfuscated Programming 2 07-20-2010 10:51 AM

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

All times are GMT -5. The time now is 09:42 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