Unix C++
Would you like to react to this message? Create an account in a few clicks or log in to continue.

printing white color using echo ?????

4 posters

Go down

printing white color using echo ????? Empty printing white color using echo ?????

Post by anand Thu Mar 11, 2010 1:53 pm

echo -e -n "\033[47m "

this line print white color.... how ???
anand
anand

Posts : 55
Points : 70
Join date : 2010-02-26
Age : 36

Back to top Go down

printing white color using echo ????? Empty Re: printing white color using echo ?????

Post by Christopher Thu Mar 11, 2010 2:04 pm

"-e" option enables the interpretation of escape sequences. To test this, execute the following commands.

Code:
$ echo "\n\n\n\n\n\n\n\n\n\n\n\n\n\n"
Code:
$ echo -e "\n\n\n\n\n\n\n\n\n\n\n\n\n\n"

hope u can notice d difference.
Christopher
Christopher
Admin

Posts : 240
Points : 429
Join date : 2010-02-26
Age : 35

https://unixcpp.forumotion.com

Back to top Go down

printing white color using echo ????? Empty Re: printing white color using echo ?????

Post by anand Thu Mar 11, 2010 2:06 pm

actually
u didn get my question ..
\033 and "[ " has some meaning .. i didn get it ... tats my question ???
anand
anand

Posts : 55
Points : 70
Join date : 2010-02-26
Age : 36

Back to top Go down

printing white color using echo ????? Empty Re: printing white color using echo ?????

Post by mightyganesh Thu Mar 11, 2010 2:14 pm

in echo command -n stands for no new line after its execution
and -e stands for enables interpretation of commands having escape sequences \

and "\033[..." is to tell the shell that its a kind of coloring script! and the other symbols which follow it tell the shell what kind of color it is

these are used for changing the color of the background and letters! (u would have seen this effect when you typing in VI editor!)
try this code!
Code:

#!/bin/bash
 # ex30a.sh: "Colorized" version of ex30.sh.
 #            Crude address database


clear                                  # Clear the screen.

 echo -n "          "
 echo -e '\E[37;44m'"\033[1mContact List\033[0m"
                                        # White on blue background
 echo; echo
 echo -e "\033[1mChoose one of the following persons:\033[0m"
                                        # Bold
 tput sgr0
 echo "(Enter only the first letter of name.)"
 echo
 echo -en '\E[47;34m'"\033[1mE\033[0m"  # Blue
 tput sgr0                              # Reset colors to "normal."
 echo "vans, Roland"                    # "[E]vans, Roland"
 echo -en '\E[47;35m'"\033[1mJ\033[0m"  # Magenta
 tput sgr0
 echo "ones, Mildred"
 echo -en '\E[47;32m'"\033[1mS\033[0m"  # Green
 tput sgr0
 echo "mith, Julie"
 echo -en '\E[47;31m'"\033[1mZ\033[0m"  # Red
 tput sgr0
 echo "ane, Morris"
 echo
read person

 case "$person" in
 # Note variable is quoted.

  "E" | "e" )
  # Accept upper or lowercase input.
  echo
  echo "Roland Evans"
  echo "4321 Floppy Dr."
  echo "Hardscrabble, CO 80753"
  echo "(303) 734-9874"
  echo "(303) 734-9892 fax"
  echo "revans@zzy.net"
  echo "Business partner & old friend"
  ;;

  "J" | "j" )
  echo
  echo "Mildred Jones"
  echo "249 E. 7th St., Apt. 19"
  echo "New York, NY 10009"
  echo "(212) 533-2814"
  echo "(212) 533-9972 fax"
  echo "milliej@loisaida.com"
  echo "Girlfriend"
  echo "Birthday: Feb. 11"
  ;;

 # Add info for Smith & Zane later.

          * )
    # Default option.
  # Empty input (hitting RETURN) fits here, too.
    echo
    echo "Not yet in database."
  ;;

 esac

 tput sgr0                              # Reset colors to "normal."

 echo

 exit 0

mightyganesh
mightyganesh

Posts : 53
Points : 92
Join date : 2010-02-26
Age : 35

http://ganeshguna.blogspot.com

Back to top Go down

printing white color using echo ????? Empty Re: printing white color using echo ?????

Post by urvershi Thu Mar 11, 2010 2:16 pm

\033 is escape character and '[47m' is escape code . As soon as console receives the message it start to process/read it, and if it found escape character (\033) it moves to escape mode, then it read "[" character and moves into Command Sequence Introduction (CSI) mode.

urvershi

Posts : 21
Points : 70
Join date : 2010-02-26

Back to top Go down

printing white color using echo ????? Empty Re: printing white color using echo ?????

Post by anand Thu Mar 11, 2010 2:18 pm

hey i found it..
\033 is an escape character ..
[47m will set foreground color to screen .... ite the escape code ....

u can try other colors by " [xxm " ..
like "[34m" for blue .....
anand
anand

Posts : 55
Points : 70
Join date : 2010-02-26
Age : 36

Back to top Go down

printing white color using echo ????? Empty Re: printing white color using echo ?????

Post by Christopher Thu Mar 11, 2010 2:24 pm

we know "\0NNN" prints the ascii character equivalent to NNN(octal value). but what is the ascii equivalent of "33"??? do values after "[" brackets means any RGB values.??
Christopher
Christopher
Admin

Posts : 240
Points : 429
Join date : 2010-02-26
Age : 35

https://unixcpp.forumotion.com

Back to top Go down

printing white color using echo ????? Empty Re: printing white color using echo ?????

Post by Christopher Thu Mar 11, 2010 2:59 pm

Christopher
Christopher
Admin

Posts : 240
Points : 429
Join date : 2010-02-26
Age : 35

https://unixcpp.forumotion.com

Back to top Go down

printing white color using echo ????? Empty Re: printing white color using echo ?????

Post by Sponsored content


Sponsored content


Back to top Go down

Back to top


 
Permissions in this forum:
You cannot reply to topics in this forum