Sponsored Content
Full Discussion: color in bash
Top Forums Shell Programming and Scripting color in bash Post 302616895 by balajesuri on Sunday 1st of April 2012 08:51:57 PM
Old 04-01-2012
printf does not output the trailing newline, by default.

So if you do this at command line:
Code:
printf "\033[2;32mHello\033[0m"

you would see hello on console in green and the prompt right next to it.
This User Gave Thanks to balajesuri For This Post:
 

4 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

How to get rid of all the weird characters and color on bash shell

Does anyone of you know how to turn off color and weird characters on bash shell when using the command "script"? Everytime users on my server used that command to record their script, they either couldn't print it because lp kept giving the "unknown format character" messages or the print paper... (1 Reply)
Discussion started by: Micz
1 Replies

2. Shell Programming and Scripting

bash: color strings in log file

hello im looking for an easy way to color specific strings in text file. simple example: cat file1 acb 1234 qwer 5678 my goal: cat file1 (color the acb red and the 5678 blue) acb 1234 qwer 5678 cheers (2 Replies)
Discussion started by: modcan
2 Replies

3. OS X (Apple)

Adding Color to bash

Hey everyone, I have come across an issue to where I am trying to create a script which changes the text color with a simple if then statement. I have seen it done with Fedora 8 but when I try and create it using my MacBook Pro running Snow Leopard it doesn't work. Funny thing is, when I use... (2 Replies)
Discussion started by: dachadster13
2 Replies

4. Shell Programming and Scripting

Bash - changing a color of a substring

Hello! I need to write a bash script for my university classes, and I came up with an idea of a program that would test the speed of typing - there is some random text that you have to rewrite, and the script measures time, number of mistakes etc. The text would be visible on the screen all... (3 Replies)
Discussion started by: xqwzts
3 Replies
CONS(9) 						   BSD Kernel Developer's Manual						   CONS(9)

NAME
cnbell, cnflush, cngetc, cngetsn, cnhalt, cnpollc, cnputc -- console access interface SYNOPSIS
#include <dev/cons.h> void cnbell(u_int pitch, u_int period, u_int volume); void cnflush(void); int cngetc(void); int cngetsn(char *cp, int size); void cnhalt(void); void cnpollc(int on); void cnputc(int c); DESCRIPTION
These functions operate over the current console device. The console must be initialized before these functions can be used. Console input polling functions cngetc(), cngetsn() and cnpollc() are only to be used during initial system boot, e.g., when asking for root and dump device or to get necessary user input within mountroothooks. Once the system boots, user input is read via standard tty(4) facili- ties. The following is a brief description of each function: cnbell() Ring a bell at appropriate pitch, for duration of period milliseconds at given volume. Note that the volume value is ignored com- monly. cnflush() Waits for all pending output to finish. cngetc() Poll (busy wait) for an input and return the input key. Returns 0 if there is no console input device. cnpollc() must be called before cngetc() could be used. cngetc() should be used during kernel startup only. cngetsn() Read one line of user input, stop reading once the newline key is input. Input is echoed back. This uses cnpollc() and cngetc(). Number of read characters is size at maximum, user is notified by console bell when the end of input buffer is reached. <Backspace> key works as expected. <@> or <CTRL>-u make cngetsn() discard input read so far, print newline and wait for next input. cngetsn() returns number of characters actually read, excluding the final newline. cp is not zero-ended before return. cngetsn() should be used during kernel startup only. cnhalt() Terminates the console device (i.e. cleanly shuts down the console hardware.) cnpollc() Switch the console driver to polling mode if on is nonzero, or back to interrupt driven mode if on is zero. cnpollc() should be used during kernel startup only. cnputc() Console kernel output character routine. Commonly, kernel code uses printf(9) rather than using this low-level interface. EXAMPLES
This waits until a <Enter> key is pressed: int c; cnpollc(1); for(;;) { c = cngetc(); if ((c == ' ' || (c == ' ')) { printf(" "); break; } } cnpollc(0); SEE ALSO
pckbd(4), pcppi(4), tty(4), wscons(4), wskbd(4), printf(9), spl(9), wscons(9) BSD
June 8, 2010 BSD
All times are GMT -4. The time now is 10:42 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy