LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
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 04-12-2023, 07:29 PM   #1
Faki
Member
 
Registered: Oct 2021
Posts: 574

Rep: Reputation: Disabled
printf with RGB colours for foreground and background


When setting colour using printf, is it better to use \033 rather than \e.

Have done

Code:
rst="\e[0m"                            # Reset to default colours
orn="\e[38;2;100;65;0m\e[48;2;0;0;0m"  # Orange on black background
The code works for

Code:
echo -e "$orn HELLO $rst"
but not for

Code:
printf '%s\n' "$orn HELLO $rst"

Last edited by Faki; 04-12-2023 at 08:59 PM.
 
Old 04-12-2023, 09:08 PM   #2
JJJCR
Senior Member
 
Registered: Apr 2010
Posts: 2,162

Rep: Reputation: 449Reputation: 449Reputation: 449Reputation: 449Reputation: 449
Try this:

Quote:
printf '%b\n' "$orn HELLO $rst"
 
  


Reply

Tags
bash



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
[SOLVED] printf $"Hello $var\n" vs. printf "Hello $var\n" -- not a typo. What is it? GrapefruiTgirl Programming 2 10-21-2010 08:21 AM
What does backslash n 033 means in echo -e "\033[1m linux"? mohit_parihar Linux - General 3 07-25-2010 08:21 PM
[SOLVED] CLI Issues -- Annoying File name: \033[A\033[B\b\b , delete how? badwizard Linux - General 11 07-25-2010 07:49 PM
[python] print "\033[5;",x,"H=>" datbenik Programming 1 01-05-2006 05:12 AM
How is 'man 3 printf' different from 'man printf' ?? purpleburple Linux - General 3 09-23-2002 12:29 AM

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

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