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 |
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.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
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.
|
|
07-09-2012, 03:55 PM
|
#1
|
LQ Newbie
Registered: Jul 2012
Posts: 11
Rep:
|
change color of text from shell script
What command (or combination of commands) do I need to use to change the color of the text from within a shell script? My teacher has me creating a menu script where the script asks for input from the user and the user chooses from a menu of options. One of the options is the calendar utility. User can hit #4 and the cal command will run automatically. My problem is that I'm supposed to make the calendar that is printed to the screen green and I cannot for the life of me figure it out...
|
|
|
07-09-2012, 04:00 PM
|
#2
|
LQ Guru
Registered: May 2009
Location: Gibraltar, Gibraltar
Distribution: Fedora 20 with Awesome WM
Posts: 6,805
|
Hello and welcome to LinuxQuestions,
Posting homework verbatim will not get you any 'points' here at LQ. Although we're all here to help out LQ users with their questions/problems regarding Linux, we will not do the work for you. What have you found out up to now? Did you do a search with Google and if so what have you found? I did a quick search on Google and the following came up:
Colorizing scripts
Advanced Bash Scripting Guide
Those should get you started. Looking forward to your participation in the forums. Have fun with Linux and remember that your teacher might be a member here at LQ too.
Kind regards,
Eric
|
|
|
07-09-2012, 04:11 PM
|
#3
|
LQ Newbie
Registered: Jul 2012
Posts: 11
Original Poster
Rep:
|
Thank you for your quick response. It's an online class and it's difficult to get the help I need. I certainly don't want anyone doing the work for me, there's still a whole script to write and I've been at it for a while now. The only thing I couldn't figure out how to do was to change the color of the output text. So you know I'm not being sneaky about my question, but am seeking help with just part of a project, here is the message I just sent my professor:
Prof,
I really cannot figure out, at all, how to change the color of the output from a shell script. I've looked on YouTube, I've looked all through the book, I've sent out a mass email to classmates (you included), I've done google searches, I've sat here at the terminal and just tried different combinations of commands and options, I've gone to the following sites:
http://losbyers.com/wordpress/2009/1...l-font-colors/
http://www.linuxhowtos.org/Tips%20an..._sequences.htm
http://www.linuxforums.org/
...and many, many more. I just cannot make it work. Would you be so kind as to walk me through how to get this done so I can get on with my last few labs? I'm beyond the point of frustration. It would be really helpful and I'd really appreciate it.
Thank You,
But if I can get this finished before he responds that would be even better.
|
|
|
07-09-2012, 09:10 PM
|
#4
|
LQ Guru
Registered: Sep 2009
Location: Perth
Distribution: Arch
Posts: 10,028
|
So you have mentioned that you can color the text. What else do you require? (sorry I have not used cal before)
|
|
|
07-09-2012, 09:27 PM
|
#5
|
LQ Guru
Registered: Sep 2009
Location: Perth
Distribution: Arch
Posts: 10,028
|
Ok ... quick search on my system and found cal
As it is text based output, try changing the text color and then executing the command, within a script, and see what happens.
If stuck, show us what you are trying and we may be able to suggest options
|
|
|
07-09-2012, 09:36 PM
|
#6
|
LQ Newbie
Registered: Jul 2012
Posts: 11
Original Poster
Rep:
|
changing text colors figured out
I figured it out...w/ a lot of help. My problem was I was trying to connect the processes of calling the calendar and making it green or whatever color, instead of separating the processes and first making output green with the echo -e "\033[32m" command and then on the next line calling the calendar utility. I was just stuck thinking about it in one way. Thanks for all the help!
|
|
|
07-09-2012, 10:01 PM
|
#7
|
LQ Guru
Registered: Oct 2004
Distribution: Arch
Posts: 5,332
|
Code:
xterm -fg green -bg black -e cal\;bash &
|
|
|
07-10-2012, 12:35 AM
|
#8
|
LQ Guru
Registered: Sep 2009
Location: Perth
Distribution: Arch
Posts: 10,028
|
@teckk - whilst that is a solution it is dependent on having xterm ... what if you are simply at a command line? (ie no X)
|
|
|
07-10-2012, 07:51 AM
|
#9
|
LQ Guru
Registered: Oct 2004
Distribution: Arch
Posts: 5,332
|
Code:
echo -e "\033[32m";cal
I see, I love LQ, never fail to learn something, on a weekly basis.
|
|
|
All times are GMT -5. The time now is 03:55 PM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|