ºìÁªLinuxÃÅ»§
Linux°ïÖú

[shellÈÕ¼Ç]echo²ÊÉ«»ØÏÔ

·¢²¼Ê±¼ä:2010-01-30 22:26:54À´Ô´:ºìÁª×÷Õß:523066680
[shellÈÕ¼Ç]echo
±à¼­:523066680
¼ÌÐø¼ÌÐø£¬Õâ´Î½«ÔÚÁ÷ˮѧӢÓïºóÃæ²¹ÉÏÒ»µã¸»ÓÐÉ«²ÊµÄ֪ʶ¡£ÎÒÒ²½¨ÒéÖ±½ÓÌøµ½ºóÃæÈ¥

ÔÚubuntuÏ£¬½«Õâ¸öÎı¾±£´æΪsh¸ñʽ£¬ÓÃgedit²é¿´£¬½«»á¿´µ½²»Í¬ÑÕÉ«µÄ½âÊÍ¡£
²¢ÐÞ¸Äϱ³¾°ÑÕÉ« ±à¼­--Ê×Ñ¡Ïî--×ÖÌåºÍÑÕÉ« £¬Ñ¡Cobalt-À¶É«»ùµ÷µÄÑÕÉ«Ö÷Ìâ¡£
ÉîÀ¶É«µ½°µµÄ±³¾°£¬¿´ÆðÀ´½«»áºÜÊæÊÊ¡£

ÏÂÃæÊÇÎÒ´ÖÖƵķ­Òë(ÎÒÈÏΪ¿ÉÖ±ÒëÇÒ¼òµ¥£¬»òÕßÎÒ²»»áµÄ£¬²»·­Òë):

echo - display a line of text
"չʾÎı¾ÐÐ"

SYNOPSIS
echo [SHORT-OPTION]... [STRING]...
echo LONG-OPTION

DESCRIPTION
Echo the STRING(s) to standard output.
"ÏÔʾ×Ö·û´®µ½±ê×¼Êä³ö¡£"

-n do not output the trailing newline
"²»Êä³öºóÃæ½ÓµÄÐÂÐÐ(ĬÈÏÊÇ×îºóÓиö»»ÐÐÂï)"
#trailing: ºóÐø

-e enable interpretation of backslash escapes
"ÔÊÐí ·´Ð±¸Ü \ (¶Ô×Ö·û)µÄתÒå"
#interpretation ½âÊÍ;˵Ã÷
#escape ÌÓ±Ü;»»Âë; ÕâÀïָתÒå

-E disable interpretation of backslash escapes (default)
"²»ÔÊÐí½âÊÍ£¬(¶ÔÓÚ)·´Ð±¸ÜתÒå×Ö·û(ĬÈÏ)"
#backslash escapes: ÏÖÔÚÎÒ·­ÒëΪ תÒÆ×Ö·û

--help display this help and exit

--version
output version information and exit

If -e is in effect, the following sequences are recognized:
"Èç¹û-eÊÇ¿ªÆôµÄ,ÒÔÏÂÐòÁн«±»Ê¶±ð"
#effect: Ч¹û;×÷ÓÃ;ЧӦ
#following: ½Ó×ŵÄ;ÏÂÒ»¸ö
#sequence: ÐòÁÐ;Ò»Á¬´®

\0NNN the character whose ASCII code is NNN (octal)
"NNN (°Ë½øÖÆ) ÊÇij¸ö×Ö·ûµÄASCIIÂë " #octal: °Ë½øÖÆ
"ÓÃ\ºó½Ó°Ë½øÖƵÄASCIIÂëÀ´±íʾ¶ÔÓ¦µÄASCII×Ö·û"
\\ backslash
#backslash: ·´Ð±¸Ü "\"

\a alert (BEL)
#¾¯¸æ òËÆ¿ÉÒÔÈ÷äÃùÆ÷ÏìÒ»Éù£¬ÎÒÕâÀïûÏì¡­¡­ ubuntu9.10

\b backspace
#Í˸ñ

\c produce no further output
"²»½øÒ»²½Êä³ö" #ÎҲµÄ,ʵ¼Ê²âÊÔºóÃæµÄ×Ö·û¶¼²»Êä³öÁË¡£
#further ½øÒ»²½µÄ

\f form feed
"(°Ù¶È×Öµä)ÌøÒ³;»»Ò³ ʵ¼Ê²âÊÔ½á¹û:Ïñ»»ÐÐ"
#form: ¸ñʽ feed:¹©¸ø£»(´òÓ¡»ú)½øÖ½

\n new line

\r carriage return
#carriage Óкü¸ÖÖÒâ˼£¬½Ó½üµÄÊÇ:µ¶¾ßÁï×ù Òâ˼¾ÍÊÇÍù»ØÁï¿©
#ÎÒ²âÊÔ½á¹û¸ú\b²î²»¶à

\t horizontal tab
"ˮƽÌø¸ñ" #horizontal ˮƽ

\v vertical tab
"´¹Ö±Ìø¸ñ" #vertical ´¹Ö±;¶¥µã

#È»ºóÎÒÌøÁËÁ½¶Î

"SEE ALSO
The full documentation for echo is maintained as a Texinfo manual. If
the info and echo programs are properly installed at your site, the
command

info coreutils 'echo invocation'

should give you access to the complete manual."

Ö´ÐÐËû˵µÄÄǾ仰£¬¾Í¿ÉÒÔͨÏò¸üÍêÕûµÄ echo ʹÓÃÊֲᡣ
Ëùν¸üÍêÕûµÄecho ÊֲᣬÎÒûÕÒµ½"¹ØÓÚ²ÊÉ«×Ö·ûµÄ¿ØÖÆ¡­¡­ "
µ¹ÊǶàÁËÁ½¸öÓÃANSCIIÂë±íʾ×Ö·ûµÄ·½Ê½

\0NNN
the eight-bit value that is the octal number NNN (zero to
three octal digits)

\NNN
the eight-bit value that is the octal number NNN (one to
three octal digits)

\xHH
the eight-bit value that is the hexadecimal number HH (one or
two hexadecimal digits)

###########################################################################
ºô£¬ÎªÁËecho¸ü¶àµÄѧϰ£¬ÎÒÒª°Ñ¡¶¸ß¼¶Bash½Å±¾±à³ÌÖ¸ÄÏ¡· ½Ì³ÌÀï¿´µ½µÄ¶«¶«ÌíÓͼӴ״ø¹ýÀ´,

### ÒýÓöÎÂä ###
{
¿ÉÒÔÔÚÓÐÉ«µÄ±³¾°ÉÏÓÃÏÂÃæµÄÄ£°åдÓÐÉ«²ÊµÄÎı¾.



echo -e '\E[COLOR1;COLOR2mSome text goes here.'



"\E[" ¿ªÊ¼×ªÒåÐòÁÐ. ·ÖºÅ·Ö¸ôµÄÊýÖµ"COLOR1" ºÍ "COLOR2" Ö¸¶¨Ç°¾°É«ºÍ±³¾°É«, ÊýÖµºÍ

É«²ÊµÄ¶ÔÓ¦²Î¼ûÏÂÃæµÄ±í¸ñ. (ÊýÖµµÄ˳Ðò²»ÊÇÓйØϵµÄ,ÒòΪǰ¾°É«ºÍ±³¾°É«ÊýÖµ¶¼ÂäÔÚ²»

ÖصþµÄ·¶Î§Àï.) "m"ÖÕÖ¹¸ÃתÒåÐòÁÐ, È»ºóÎı¾ÒÔ½áÊøµÄתÒåÖ¸¶¨µÄÊôÐÔÏÔʾ.



ҲҪעÒâµ½Óõ¥ÒýºÅÒýÓÃÁËecho -eºóÃæµÄÓàÏÂÃüÁîÐòÁÐ.



ϱíµÄÊýÖµÊÇÔÚ rxvt ÖÕ¶ËÔËÐеĽá¹û. ¾ßÌåЧ¹û¿ÉÄÜÔÚÆäËûµÄ¸÷ÖÖÖÕ¶ËÉϲ»Ò»Ñù.



table 33-1. תÒåÐòÁÐÖÐÊýÖµºÍ²ÊÉ«µÄ¶ÔÓ¦



====================

É«²Ê Ç°¾°É« ±³¾°É«

ºÚ 30 40

ºì 31 41

ÂÌ 32 42

Ȯ 33 43

˦ 34 44

Ñóºì 35 45

Çà 36 46

°× 37 47

====================
}


ÎÒubuntu9.10ϲâÊÔ 37ÊǻҰ×É«£¬38,39¸ü°×£¬²»¹ý£¬»¹ÓиöתÒåÐòÁпÉÒÔ¼Ó´Ö¸ßÁÁµÄ

×¢ÒâËû˵µÄ£º"ÊýÖµµÄ˳Ðò²»ÊÇÓйØϵµÄ,ÒòΪǰ¾°É«ºÍ±³¾°É«ÊýÖµ¶¼ÂäÔÚ²»

ÖصþµÄ·¶Î§Àï"
ËùÒÔ
echo -e "\E[37;40mSTR"
µÄ½á¹ûµÈͬÓÚ
echo -e "\E[40;37mSTR"

### Õâ¸öÊÇÇ°Ã沿·ÖµÄÄÚÈÝ£¬ÎÒתÔÚºóÃæ ###
{
×î¼òµ¥Ò²¿ÉÄÜÊÇ×îÓÐÓõÄANSIתÒåÐòÁÐÊǼӴÖÎı¾, \033[1m ... \033[0m. \033 ´¥·¢×ªÒåÐò

ÁÐ, ¶ø "[1" ÆôÓüӴÖÊôÐÔ, ¶ø"[0" ±íʾÇл»»Ø½ûÓüӴÖ״̬. "m"Ôò±íʾÖÕÖ¹Ò»¸öתÒåÐòÁÐ.



bash$ echo -e "\033[1mThis is bold text.\033[0m"



Ò»ÖÖÏàËƵÄתÒåÐòÁпÉÇл»Ï»®ÏßЧ¹û (ÔÚ rxvt ºÍ aterm ÉÏ).



bash$ echo -e "\033[4mThis is underlined text.\033[0m"



×¢Òâ: echoʹÓÃ-eÑ¡Ïî¿ÉÒÔÆôÓÃתÒåÐòÁÐ.



ÆäËûµÄתÒåÐòÁпÉÓÃÓÚ¸ü¸ÄÎı¾»ò/ºÍ±³¾°É«²Ê.



bash$ echo -e '\E[34;47mThis prints in blue.'; tput sgr0



bash$ echo -e '\E[33;44m'"yellow text on blue background"; tput sgr0



bash$ echo -e '\E[1;33;44m'"BOLD yellow text on blue background"; tput sgr0



×¢Òâ: ͨ³£Îªµ­É«µÄÇ°¾°É«Îı¾ÉèÖôÖÌåЧ¹ûÊǽϺõÄ.



tput sgr0 °ÑÖÕ¶ËÉèÖûָ´ÎªÔ­Ñù. Èç¹ûÊ¡ÂÔÕâÒ»¾ä»áʹºóÐøÔÚ¸ÃÖն˵ÄÊä³öÈÔΪÀ¶É«.



×¢Òâ: ÒòΪtput sgr0 ÔÚijЩ»·¾³Ï²»Äָܻ´ÖÕ¶ËÉèÖÃ, echo -ne \E[0m »áÊǸüºÃµÄÑ¡Ôñ.
}

ÎÒ×îºóµÄÌáÐÑÊÇ£¬ÌرðÊÇ×÷ÌØЧµÄʱºò£¬¿ÉÄÜÖ»ÏëÒªÒ»¸ö·½¸ñµÄ ±³¾°ÑÕÉ«¸Ä±ä£¬
¶ø±äÑÕÉ«ºóÊÇÕû¸ö´°¿Ú½ÓÏÂÀ´µÄ²¿·Ö±³¾°É«¶¼ÊDZäÉ«µÄ¡£Õâ¾ÍÓôÃÆ£¬µ±Ê±ÎÒÏëµ½µÄÊǺó½Ó \E[Ô­À´µÄÎı¾ÑÕÉ«;Ô­À´µÄ±³¾°É«m
À´¸ôÀë¸Õ¸Õ¸Ä¶¯¹ýµÄÑÕÉ«¡£

Ô­À´ÒýÓò¿·ÖÌáµ½µÄ tput sgr0 ¿ÉÒÔÖ±½Ó»Ö¸´Ä¬Èϵģ¬×Ô¼º¸ù¾ÝÐèÇóÑ¡Ôñ¿©¡£

СЧ¹û£º[code]
#!/bin/bash
#Author: 523066680@linux110
for ((i=0;i<=80;i++))
do
str="$str "
newline="$newline
"
done

let x=0,tmpy=-10,xadd=1,xaddadd=1,yadd=1
while :
do
let x+=xadd,xadd+=xaddadd,tmpy+=yadd,y=tmpy+10,orthe=21-y,color=x%8+30,c2=color+11
clear
echo "${newline:0:$y}"
echo -e "${str:0:$x} \E[${color};${c2}mO \E[33;40m${color} ${c2} "
echo "${newline:0:$orthe}"
if [ ${xadd/-/} -ge 7 ] ;then let xaddadd*=-1 ;fi
if [ ${tmpy/-/} -ge 10 ] ;then let yadd*=-1; fi
sleep 0.1
done
[/code]
ÎÄÕÂÆÀÂÛ

¹²ÓÐ 9 ÌõÆÀÂÛ

  1. aaa0000306 ÓÚ 2014-05-01 03:11:25·¢±í:

    ºÃ

  2. lianggecai ÓÚ 2010-11-22 18:54:26·¢±í:

    лл¥Ö÷°¡£¬Õâ¸öÌ«ºÃÁË¡£Ð»Ð»£¡

  3. lpy_study ÓÚ 2010-03-31 12:30:44·¢±í:

    ¶¥

  4. cool_lee ÓÚ 2010-03-29 10:23:56·¢±í:

    ¶¥ÏÂÏÈ

  5. 523066680 ÓÚ 2010-03-27 18:34:50·¢±í:

    Â¥ÉÏÍ·ÏñºÃÌرð

  6. zhangyinghao452 ÓÚ 2010-03-27 04:32:58·¢±í:

    Õâ¸öÓÐÒâ˼

  7. xiaokeding ÓÚ 2010-02-19 23:02:18·¢±í:

    ²»¶®£¬¶¥Ò»ÏÂÏÈ

  8. wyfwyt ÓÚ 2010-02-09 19:51:51·¢±í:

    ¸Ðл ¸Ðл¥Ö÷ Ç¿ÁÒÖ÷³Ö

  9. tbtnel ÓÚ 2010-01-31 08:14:39·¢±í:

    Éî°Â°¢