Shell scripts commonly used ANSI escape codes for color output.
Following table shows Numbers representing colors in Escape Sequences.
Color | Foreground | Background |
Black | 30 | 40 |
Red | 31 | 41 |
Green | 32 | 42 |
Yellow | 33 | 43 |
Blue | 34 | 44 |
Magenta | 35 | 45 |
Cyan | 36 | 46 |
White | 37 | 47 |
The numbers in the above table work for xterm terminal.Result may vary
for other terminal emulators.
Use the following template for writing colored text.
echo -e "\033[COLORm Sample text"
The "\033[" begins the escape sequence.You can also use "\e[" instead
of "\033[". COLOR specifies a foreground color, according to the table
above.The "m" terminates escape sequence, and text begins immediately
after that.
Note: With an echo, the -e option enables the escape sequences.You can
also use printf instead of echo.
printf "\e[COLORm sample text\n"
To print Green text
echo -e "\033[32m Hello World"
or
printf "\e[32m Hello World"
The problem with above statement is that the blue color that starts
with the 32 color code is never switched back to the regular color, so
any text you type after the prompt and even prompt also is still in the
Green color.
To return to the plain, normal mode, we have yet another sequence.
echo -e "\033[0m"
Now you won't see anything new on the screen, as this echo statement
was not passed any string to display. But it has done its job, which
was to restore the normal viewing mode. Whatever yor type now will be
avoid of any fancy effects.
Escape sequence also allow you to control the manner in which
characters are displayed on the screen.
The following table summarizes numbers representing text attributes
in Escape Sequences.
ANSI CODE | Meaning |
0 | Normal Characters |
1 | Bold Characters |
4 | Underlined Characters |
5 | Blinking Characters |
7 | Reverse video Characters |
Note: Blink attribute doesn't work in any terminal emulator, but it
will work on the console.
Combining all these Escape Sequences, you can get more fancy effect.
Use the following template for writing colored text on a colored
background.
echo -e "\033[COLOR1;COLOR2m sample text\033[0m"
The semicolon separated numbers "COLOR1" and "COLOR2" specify a
foreground and a background color.The order of the numbers does not
matter, since the foreground and background numbers fall in non-
overlapping ranges."m" terminates the escape sequence, and the text
begins immediately after that.Although setting the colors separately
also work (i.e. \033[44m\033[32m).
There are some differences between colors when combining colors with
bold text attribute.
The following table summarises these differences.
Bold off | color | Bold on | color |
0;30 | Balck | 1;30 | Dark Gray |
0;31 | Red | 1;31 | Dark Red |
0;32 | Green | 1;32 | Dark Green |
0;33 | Brown | 1;33 | Yellow |
0;34 | Blue | 1;34 | Dark Blue |
0;35 | Magenta | 1;35 | Dark Magenta |
0;36 | Cyan | 1;30 | Dark Cyan |
0;37 | Light Gray | 1;30 | White |
The following shell script prints all the colors and codes on the
screen.
#!/bin/bash
# This script echoes colors and codes
echo -e "\n\033[4;31mLight Colors\033[0m \t\t\033[1;4;31mDark Colors\033[0m"
echo -e "\e[0;30;47m Black \e[0m 0;30m \t\e[1;30;40m Dark Gray \e[0m 1;30m"
echo -e "\e[0;31;47m Red \e[0m 0;31m \t\e[1;31;40m Dark Red \e[0m 1;31m"
echo -e "\e[0;32;47m Green \e[0m 0;32m \t\e[1;32;40m Dark Green \e[0m 1;32m"
echo -e "\e[0;33;47m Brown \e[0m 0;33m \t\e[1;33;40m Yellow \e[0m 1;33m"
echo -e "\e[0;34;47m Blue \e[0m 0;34m \t\e[1;34;40m Dark Blue \e[0m 1;34m"
echo -e "\e[0;35;47m Magenta \e[0m 0;35m \t\e[1;35;40m DarkMagenta\e[0m 1;35m"
echo -e "\e[0;36;47m Cyan \e[0m 0;36m \t\e[1;36;40m Dark Cyan \e[0m 1;36m"
echo -e "\e[0;37;47m LightGray\e[0m 0;37m \t\e[1;37;40m White \e[0m 1;37m"
OUTPUT:
Some examples:
Block background and white text
echo -e "\033[40;37m Hello World\033[0m"
Reverse video text attribute option interchanges fg and bg colors.
Bellow statement prints block on white
echo -e "\033[40;37;7m Hello World\033[0m"
echo -e "\033[33;44m Yellow text on blue background\033[0m"
echo -e "\033[1;33;44m Bold yellow text on blue background\033[0m"
echo -e "\033[1;4;33;44mBold yellow underlined text on blue background\033[0m"
The "tput" command:
Other than echo there is a command called tput using which we
can control the way the output is displayed on the screen.But it is
less flexible than ANSI escape sequences.
Hi. This was excellent info indeed, thanks so much for your help!
ReplyDeleteI would like to pipe all my output to a file and retain the color settings using >>
Any ideas how to do that please?
Thanks
hi this is a nice post, was actually going to put up a post on it my self, but as you have such a well written post on it, will be providing a link to your post in my post. Hope that is fine.
ReplyDeleteHey,
Delete10/10 !!! Thank you for making your blogs an embodiment of perfection and simplicity. You make everything so easy to follow.
Tested mainly with Microsoft Cloud OCR.
I’ve used the same exact image from UiPath and from normal C# code.
The latter works normally (although the results are not that great).
The former throws an InvalidImageInput for all configurations I could think of - passing UiPath.Core.Image, System.Drawing.Image, loading from file, using the activity GetOcrText with nested engine, using the
Uipath Training USA
engine activity directly… always same result
Thanks a lot. This was a perfect step-by-step guide. Don’t think it could have been done better.
Shukran,
Awesome Thanks for sharing really helpful
ReplyDeletevery helpful!
ReplyDeleteHi Man,
DeleteNice tutorial! Let's keep our fingers crossed that this works. I would like to put this all to rest.
I’m learning the UiPath Level 1 - Foundation Training & trying to add the event action Get Text. When I’m trying to assign the value to the variable, encountering below error.
Compilor error Encountered processing expression “Set Name: returnText”. Expression Expected.
Looks like there is some syntax error. Can someone help me with this?
Excellent tutorials - very easy to understand with all the details. I hope you will continue to provide more such tutorials.
Thanks,
Amazing blog dude, Its in my opinion best blog for bash script related things, I really love your examples and scripts and more importantly your explanation, I have now added you as google friend and will look forward for more quality articles and tips.
ReplyDeleteJavin
10 examples of using VI Editor in UNIX
It's very nice explained making very easy to understand this topic for bash.
ReplyDeleteThank you!
thanks a lot was use-full for me
ReplyDeleteI am writing my scripts now colorfully.
ReplyDeleteThank you very much.
Thank u very much . . .
ReplyDeleteHi i am S.Abdul Kareem
ReplyDeleteReally This is web site very nice ....
Thank you..... Very Much Up-loaders
Really Helpful. Thanks
ReplyDeleteThis is very helpul. But when i am trying to send a coloured text file via mail then output comes withour colours.
ReplyDeleteCan you plz help.
Thank you! This should really be the number one result when searching for: Color bash output. But, as the eighth result... you were the only helpful one!
ReplyDeleteNote: I didn't clearly get the underline from above. I found that you can do your two colors and then the attribute you want. [color1;color2;attributem
(the 'm' still escapes)
This is great, very helpful.
ReplyDeleteI was able to use this to highlight different fields in a log file using AWK:
tail -f LOGFILE | while read LINE; do echo "$LINE" | awk -F'\t' '{ printf "%-20s %40s %20s %s %s %s %s %s\n", "\33[0;32;40m" $1 "\33[0m",$7,"\33[37m"$13"\33[36m",$14,$19,$21,$22,"\33[35m"$24 }'
; done
(I had to do the read/echo bit because tail-f wouldn't work otherwise. Is there a better way around that?)
This is absolutely beneficial, thank you so much
ReplyDeleteNice post. Thanx a ton. Keep posting stuff like this..
ReplyDeleteI love Balck, it's my favorite color.
ReplyDeleteThank You.. Dharmin
ReplyDeletethank you .... really helpful
ReplyDeleteThanks man!
ReplyDeleteA very helpful article.
I had a lot of fun playing with those colors.
:-))
Gracias!.. very useful.
ReplyDeleteAwesome
Very easy, thanks :D
ReplyDeleteHi All ..need help ...
ReplyDeletewhile running this command on console :
echo -e "\e[;32m Hello World\e[0m"
getting output in green color , but when I am trying to save this in file , output in the file is like this
^[[;32m Hello World^[[0m
Can anyone please help out?
It helped me to beautify my shell script utility
ReplyDelete什么叫惨败是什么意思?
ReplyDeleteGreat idea and this article tell us how maintain your shell scripts and how to update time and date when any issue in shell script thanks for sharing personal statement review service .
ReplyDeleteFun article !!!
ReplyDeleteIf you need any tips on writing you can take a look at this page to improve your writing skills.
ReplyDeleteI truly love your website.. Excellent colors & theme.
ReplyDeleteDid you build this site yourself? Please reply back as I’m looking to create my own blog
and would like to find out where you got this from or just what
the theme is called. Kudos!
Wonderful work! This is the type of info that should be shared around the internet.
ReplyDeleteShame on the seek engines for now not positioning this post upper!
Come on over and consult with my site . Thanks
=)
Hello there! This article couldn’t be written any better!
ReplyDeleteLooking at this post reminds me of my previous roommate!
He continually kept talking about this. I most
certainly will forward this post to him. Pretty sure he will have a good read.
Thank you for sharing!
Great web site. A lot of helpful information here.
ReplyDeleteI am sending it to several buddies ans additionally sharing in delicious.
And naturally, thanks on your effort!
Hi mates, its fantastic article about cultureand entirely explained, keep it up all the time.
ReplyDeleteI pay a visit day-to-day some websites and blogs to read posts,
ReplyDeleteexcept this website provides quality based content.
Hey there are using WordPress for your site platform?
ReplyDeleteI’m new to the blog world but I’m trying to get started and set up
my own. Do you need any coding expertise to make your own blog?
Any help would be greatly appreciated! Jual Boneka Wisuda | Jaket Bomber Pria
Galaxy S9 launch a new smartphone with new technology Galaxy S9.
ReplyDeleteThanks
ReplyDeletestafaband
Nice broo
ReplyDeleteThanks your post
ReplyDeleteurm web solutions is a leading Seo company in noida.
ReplyDeleteok i'm bookmark in post
ReplyDeleteFor some students it may be really difficult to write an essay. However they can overcome the difficulties by ordering an essay from https://thepaperwriting.com/research-paper-writing.
ReplyDeleteThis comment has been removed by the author.
ReplyDeleteThis comment has been removed by the author.
ReplyDeletethis is the great website for the color scripts
ReplyDeleteBest SEO Company in Noida
very helpful information on colouring scripts.sell pets online ON pet selling website
ReplyDeleteonline courses in india
ReplyDeleteAn obligation of appreciation is all together to share steady information, I really like your beginning and end post. I will bookmark your blog for future updates.
Thank you for sharing this post. I appreciate it. I really like your beginning and end post. we are mobile app development company NYC and again Thank you for sharing!
ReplyDeleteHi Venu,
ReplyDeleteHip Hip Hooray! I was always told that slightly slow in the head, a slow learner. Not anymore! It’s like you have my back. I can’t tell you how much I’ve
learnt here and how easily! Thank you for blessing me with this effortlessly ingestible digestible content.
I need to install security update KB2716429 on my Windows Server 2008R2 to update the SQL Server 2005 SP4 Windows Internal Database from version 2005.90.5000.0 to version 2005.90.5069.0.
The SQL Server Instance is microsoft##ssee.
The file that needs to be updated is C:\windows\SYSMSI\SSEE\MSSQL.2005\MSSQL\Binn\sqlservr.exe
When I tried to install the patch, I got this message "This machine does not have a product that matches this installation package"
THANK YOU!! This saved my butt today, I’m immensely grateful.
Kind Regards,
Morgan lee
Hi There,
ReplyDeleteAwesome article. Thanks for making that available. I've been using your help to build my own POC and will publish the steps in another blog soon.
UiPath:
Visual Design - Faster Implementation
Build Modular Automation and Reuse at the workflow level. Extend UiPath functionality via custom activities or various integration can be used for various integration.
Can be used for various integration services with different workflow modules hence scoring high on re usability.
Anyways great write up, your efforts are much appreciated.
Cheers,
David
Olà,
ReplyDeleteFor now, your best method for reordering the sheets is the manual up and down arrows in the Drawing Sheets dialog.
In testing automation, I was able to use Document.CopySheet and Sheet.Delete to actually reorder the sheets, but CopySheet does not produce exact copies if you have any cells that have been modified using the Editor Control switches to Allow Cell Text/Graphics Edits. Also, the results were automatically saved to the design, so undo was not possible. User beware!
I wish I had better news. This looks like a candidate for Mentor Ideas Uipath certification .
It was cool to see your article pop up in my google search for the process yesterday. Great Guide.
Keep up the good work!
Thanks a heaps,
Kevin
Hi There,
ReplyDeleteGratitude for putting up this prolific article! You truly make everything a cake walk. Genuinely good stuff, saving time and energy.
I might have misinterpreted your question. By the wordings "in AAE" I assumed it to be column AAE of Excel, but I think you may want to know how to find the the total number of columns in an Excel sheet and below are the commands in Automation Anywhere.
-Open Worskheet: Either New or existing
-Activate sheet: Activate the required sheet
- Go to cell: A1
-Insert keystrokes - Control and Right arrow
Here there are two options:
i. If the sheet contains data in the first row: then you need to Insert these keystrokes twice so that it will take you to the last column (or can set it to maximum no. of times if you do not know how the 1st row is)
ii. If the sheet does not contain any data then only once.
-Set cell: 'Set Cell' to insert the formula as "=Column()"
This will give the result as shown in the screenshot.
- Then you can either close the worksheet without saving Or just Set cell this cell back to blank so that the formula is removed.
Once again thanks for your tutorial.
Obrigado,
Radhey
I like people sharing such information, it is very nice of them.
ReplyDeleteHola peeps,
ReplyDeleteMuchas Gracias Mi Amigo! You make learning so effortless. Anyone can follow you and I would not mind following you to the moon coz I know you are like my north star.
I'm a manual/Automation tester with knowledge in Selenium but I keep seeing QTP everywhere. Do i need to Learn QTP as well? I know learning more technologies and tools is always good but post your comments based on the question "Is it necessary to learn QTP even when you know Selenium?" pls answer the question with today's selenium and QTP market and importance in mind also will it increase my odds for paid cycles in Utest? UiPath Training Tutorial
Appreciate your effort for making such useful blogs and helping the community.
Many Thanks,
Ajeeth
This article is very much helpful and i hope this will be an useful information for the needed one.Keep on updating these kinds of informative things...
ReplyDeleteEmbedded System training in Chennai | Embedded system training institute in chennai | PLC Training institute in chennai | IEEE final year projects in chennai | VLSI training institute in chennai
Shell scripts commonly used ANSI escape codes for color output. Thanks Admin for sharing such a useful post. Now I am a internet marketing company and this time i need this coding. finally got it.
ReplyDeleteBy and by, on the off chance that you have not paid inside the predefined course of events, your credit will "move over" and you will be charged high loan costs and expenses.www.aaa1autotitleloans.com/chicago
ReplyDeleteI¡¦ve learn some excellent stuff here. Definitely price bookmarking for revisiting. I surprise how so much attempt you put to create the sort of fantastic informative website.
ReplyDeleteI’m not sure where you are getting your information, but great topic. I needs to spend some time learning more or understanding more. Thanks for wonderful information I was looking for this info for my mission.
ReplyDeleteHello, all thanks for sharing, I think this is an informative post and it is very useful and knowledgeable. I really enjoyed reading this post. big fan, thank you!SEO company in Chennai
ReplyDeleteValuable information. Fortunate me I found your web site by accident, and I am surprised why this coincidence didn’t came about earlier! I bookmarked it.
ReplyDelete