Ted's Blog

Happy coding

shell用到ANSI控制码汇总

Ted posted @ 2008年9月10日 06:08 in shell with tags shell , 6382 阅读

我们在编写shell脚本时,如果要实现某种特殊功能(只对当前shell起作用),就需要ANSI的控制码。

比如我要让终端下字符颜色改换为绿色的,可以用
  root$ echo -e "\033[40;32"
要偷懒,将当前光标移动到第3行第1列的地方,用到
  root$ echo -ne "\33[3;1H"

上面这些都是实际的例子,要应用好还要学好ANSI控制码的相关代码,如下:

\33[30m -- \33[37m  设置前景色
\33[40m -- \33[47m  设置背景色
\33[nA  光标上移n行
\33[nB  光标下移n行
\33[nC  光标右移n行
\33[nD  光标左移n行
\33[K   清除从光标到行尾的内容
\33[s   保存光标位置
\33[u   恢复光标位置
\33[y;xH设置光标位置
\33[?25l  隐藏光标
\33[?25h  显示光标
\33[2J  清屏
\33[0m  关闭所有属性
\33[1m  设置高亮度
\33[4m  下划线
\33[5m  闪烁
\33[7m  反显
\33[8m  消隐

注意:使用不同的shell,也会用到不同的转义的,看下面的例子:

/home/lee#echo "\\033[32mddd"
ddd
/home/lee#
/home/lee#bash
/home/lee#echo "\\033[33maddd"
\033[33maddd
/home/lee#exit
/home/lee#echo "\\033[34maddd"
addd
/home/lee#echo $0
-ksh
/home/lee#

Avatar_small
play risk free 说:
2018年11月17日 20:47

If you want the best interesting board play the online latest most amazing game for he players get free online have the fun fun forever so share the site with your friends thanks.

Avatar_small
Oliver Donaldson 说:
2020年7月29日 05:15

The reason behind the concept that the education is his compulsory tool and the devise of the life is that <a href="https://www.bestbritishwriter.com/myassignmenthelp-com-review/">my assignment help review</a> people now know with the circumstance that the educations will intensification the quality of their drudgery. And the circumstances of the education will offer with the huge number of the welfares.

Avatar_small
jener 说:
2020年11月14日 20:52
Tech is to transfer something to other person. Teching a simple word with a lot of meaning and with lot of emotions behind it. Tech is also technology by gas grills las vegas. Technology is good for transformation in good way.
Avatar_small
Robinjack 说:
2020年12月07日 23:46

If the answer is no, you have nothing to lose by asking if another day, place, time, or event would suit them. Listen to the response carefully. Often people really are tied up working late, taking care of a sick parent, getting out of a relationship, studying, or being distracted and would be willing to consider an invitation in the future, just not now. speed dating

Avatar_small
Robinjack 说:
2020年12月10日 16:49

Sorry for the huge review, but I’m really loving the new Zune, and hope this, as well as the excellent reviews some other people have written, will help you decide if it’s the right choice for you. instagram followers panel

Avatar_small
Robinjack 说:
2020年12月21日 01:04

There are playing conditions, injuries, home or away games, players health, defense, offense, past performance, coaches, importance of match, rivalries to name a few just to calculate a very precise outcome.   bet88

Avatar_small
Robinjack 说:
2020年12月21日 20:32

I don’t commonly comment but I gotta state regards for the post on this perfect one : D. meeting desk

Avatar_small
Robinjack 说:
2020年12月24日 22:38

Something that will allow you to more likely show a profit than a loss at the end of a string of betting events. 12bet.com

Avatar_small
Robinjack 说:
2020年12月30日 23:44

As a successful sports better, it is strategies like this that will mean that pretty soon you really can build up a huge cash pot. Getting the bets right is still critical, but if managing money can make a trader successful when they are only right 30% of the time then just imagine the success you can have too.   kqxsmb

Avatar_small
Robinjack 说:
2020年12月31日 21:35

When you're looking for top-rated luxury transportation companies for car shipping, we are the right option in this matter. We are a car transportation company that can Cargo and freight transportation. You can trust as we take care of your car as if it was our own. Call us at (800) 392-1446!

Avatar_small
Robinjack 说:
2021年1月11日 06:07

DJ Indiana Jones has died at the age of 50, Friday, December 4th, 2020. We are yet to learn his cause of death. No health issues or other causes of death has been associated to his passing at this time. April Bowlby Death

Avatar_small
Robinjack 说:
2021年1月11日 20:50

I like this site its a master peace ! Glad I detected this on google . Apartment in Budapest

Avatar_small
Robinjack 说:
2021年1月18日 18:06

Oopsmight have spoken too soon. Young teams dont know how to play late in games, especially playoff games. Total self-destruction. Can they now learn to win? Go Cs. budapest real estate

Avatar_small
Robinjack 说:
2021年1月24日 21:44

I am not sure where you’re getting your information, but good topic. I needs to spend some time learning more or understanding more. Thanks for great info I was looking for this information for my mission. legal website to buy nembutal

Avatar_small
Robinjack 说:
2021年1月30日 18:22

Youre so cool! I dont suppose Ive read anything like this before. So nice to search out any individual with some original thoughts on this subject. realy thank you for starting this up. this website is one thing that’s wanted on the web, somebody with a bit of originality. useful job for bringing something new to the internet! online casino

Avatar_small
Robinjack 说:
2021年2月17日 21:46

You need to take part in a contest personally of the most effective blogs over the internet. I’m going to suggest this web site! ems software

Avatar_small
UMAIR 说:
2021年2月23日 18:04

No wonder why I had higher hopes inwww.signnow.com/features/write-on-pdf-documentwrite-on-pdf-document. As I though it would go the best for me. But all thing became messer than before,the support was also quit slow.

Avatar_small
amelia 说:
2021年3月13日 00:05

I am cheerful to locate your recognized method for composing the post. Presently you make it simple for me to comprehend and actualize the idea. Much obliged to you for the post.  Buy DMT

Avatar_small
amelia 说:
2021年3月15日 00:24

This substance is composed exceptionally well. Your utilization of organizing when mentioning your focuses makes your objective facts clear and straightforward. Much obliged to you.  sunglasses in bulk

Avatar_small
amelia 说:
2021年3月17日 04:55

Pleasant web journal and totally exceptional. You can improve yet despite everything I say this perfect.Keep striving generally advantageous.  먹튀검증

Avatar_small
amelia 说:
2021年3月18日 20:35

Very nice article, I enjoyed reading your post, very nice share, I want to twit this to my followers. Thanks!.  tote bags wholesale

Avatar_small
amelia 说:
2021年3月18日 20:35

hi!! Exceptionally fascinating exchange happy that I ran over such educational post. Keep doing awesome. Happy to be a piece of your net group.  wholesale fashion accessories

Avatar_small
Asia Gaming 说:
2021年4月07日 18:22

Hi Jessi. I dont see any sense, because Mccampbell has explaned everything in details. Just read the upper comments!

Avatar_small
amelia 说:
2021年4月10日 06:34

Exceptionally helpful data. Would like to see more posts soon!.  รีวิวUFA365

Avatar_small
amelia 说:
2021年4月11日 03:54

I've perused some well done here. Certainly worth bookmarking for returning to. I shock the amount of exertion you put to make such an incredible instructive site.  รีวิวufa800

Avatar_small
chalsea 说:
2021年4月15日 01:47

Respecting the time and exertion you put into your site and nitty gritty data you offer!..  How to join illuminati for fame

Avatar_small
chalsea 说:
2021年4月22日 04:11

It is an awesome site.. The Design looks great.. Continue working like that!.  Network Cable Installation

Avatar_small
Professional Window 说:
2021年4月22日 13:56

Rest assured, DMC cleaning & maintenance is here. DMC cleaning & maintenance is ready to serve its customers in the best possible way

Avatar_small
chalsea 说:
2021年4月24日 04:07

This is a truly good site post. Not too many people would actually, the way you just did. I am really impressed that there is so much information about this subject that have been uncovered and you’ve done your best, with so much class. If wanted to know more about green smoke reviews, than by all means come in and check our stuff.  우리카지노

Avatar_small
chalsea 说:
2021年5月04日 00:51

Extremely helpful data. Would like to see more posts soon!.  sitecheckthis

Avatar_small
chalsea 说:
2021年5月18日 00:19

Hey, I discover perusing this article a delight. It is amazingly useful and intriguing and all that much anticipating perusing a greater amount of your work..  cryptocurrency investigation

Avatar_small
amelia 说:
2021年5月22日 04:13

A debt of gratitude is in order for setting aside an ideal opportunity to examine that, I feel unequivocally about this thus truly like becoming acquainted with additional on this sort of field. Do you psyche overhauling your blog entry with extra understanding? It ought to be truly helpful for every one of us.  aka ms

Avatar_small
digitaler planer 说:
2021年5月26日 13:23

Nice and concise article, many things i never knew. . . We never know how much talent is devastated this way.

Avatar_small
ch 说:
2021年5月29日 18:06

I take in some new stuff from it as well, a debt of gratitude is in order for sharing your data.  click here

Avatar_small
ch 说:
2021年5月29日 23:40

I'm happy to see the immense subtle element here!.  Rent a car Novi Sad

Avatar_small
ch 说:
2021年6月05日 03:41

Amazing article! I need individuals to know exactly how great this data is in your article. It's fascinating, convincing substance. Your perspectives are much like my own particular concerning this subjec Park Magazine NY

Avatar_small
ch 说:
2021年6月05日 05:52

A debt of gratitude is in order for your data, it was truly extremely helpfull..  read Check post

Avatar_small
chalsea 说:
2021年6月06日 19:43

Magnificently composed article, if just all bloggers offered the same substance as you, the web would be a much better place..  website

Avatar_small
ch 说:
2021年7月07日 05:39

This is really the sort of data I have been attempting to discover. Much thanks to you for composing this data.  Louisiana Business Resource Group

Avatar_small
ch 说:
2021年7月12日 04:38

Much obliged for your post. I've been considering composing an extremely practically identical post in the course of the last couple of weeks, I'll most likely keep it quick and painless and connection to this rather if thats cool. Much obliged.  click more

Avatar_small
ch 说:
2021年7月15日 19:14

Much obliged to you for such an elegantly composed article. It's brimming with quick data and captivating depictions. Your perspective is the best among numerous.  login joker123

Avatar_small
ch 说:
2021年7月30日 00:21

I havent any word to appreciate this post.....Really i am impressed from this post....the person who create this post it was a great human..thanks for shared this with us. Superhero Bobblehead

Avatar_small
ch 说:
2021年8月01日 04:45

Magnificent site you have here, so much cool data!..  Fast PCR

Avatar_small
ch 说:
2021年8月11日 00:04

You’ve got some interesting points in this article. I would have never considered any of these if I didn’t come across this. Thanks!. UKAS registered laboratories

Avatar_small
Robinjack 说:
2021年8月22日 22:33

You should consider taking part in a contest for one of the best blogs on the web. I will suggest this websites! meeting room display

Avatar_small
ch 说:
2021年8月29日 23:35

Much thanks for composing such an intriguing article on this theme. This has truly made me think and I want to peruse more.  Branding

Avatar_small
Robinjack 说:
2021年9月06日 21:17

I’d must check with you here. Which isn’t some thing It’s my job to do! I enjoy reading an article that may get people to believe. Also, thank you for allowing me to comment! we buy homes fast cash san diego

Avatar_small
ch 说:
2021年9月08日 03:07

Magnificent and intriguing article. Awesome things you've generally imparted to us. Much obliged. Simply keep making this kind out of post.  Commercial Pest Control in Melbourne

Avatar_small
ch 说:
2021年9月12日 01:45

thanks for the tips and information..i really appreciate it.. Pharmacy Referral Service

Avatar_small
Robinjack 说:
2021年9月18日 19:43

The Commodore At Canberra by JBE. Hotline 61006226. Get Discounts, Direct Developer Price, Brochure, Floor Plan & Price List. The Commodore Floor Plan

Avatar_small
Robinjack 说:
2021年10月06日 19:45

Wonderful site you have here but I was wondering if you knew of any user discussion forums that cover the same topics discussed here? I’d really like to be a part of online community where I can get comments from other knowledgeable people that share the same interest. If you have any suggestions, please let me know. Appreciate it! fourth avenue residences showflat

Avatar_small
ch 说:
2021年10月17日 22:13

Thanks for sharing this quality information with us. I really enjoyed reading. Will surely going to share this URL with my friends. best weed storage

Avatar_small
ch 说:
2021年10月22日 00:40

This is really a nice and informative, containing all information and also has a great impact on the new technology. Thanks for sharing it Content writing services

Avatar_small
Robinjack 说:
2021年11月07日 19:50

Thanks for writing this. I really feel as though I know so much more about this than I did before. Your blog really brought some things to light that I never would have thought about before reading it. You should continue this, Im sure most people would agree youve got a gift. slime website

Avatar_small
ch 说:
2021年12月01日 18:38

Much obliged to you for extremely usefull data.. Social Media Management

Avatar_small
ch 说:
2021年12月19日 18:47

Fabulous web journal! Do you have any tips and indications for trying authors? I'm wanting to begin my own particular site soon however I'm somewhat lost on everything. Would you propose beginning with a free stage like WordPress or go for a paid alternative? There are such a large number of alternatives out there that I'm totally overpowered .. Any proposals? Much obliged! https://voyance-tel-avenir.com

Avatar_small
ch 说:
2022年2月28日 00:32

Much thanks to you for another awesome article. Where else might anyone be able to get that sort of data in such an impeccable method for composing? I have a presentation one week from now, and I am on the search for such data. easyสล็อต

Avatar_small
ch 说:
2022年2月28日 05:29

I can see that you are an expert at your field! I am launching a website soon, and your information will be very useful for me. เครดิตฟรี 100 120

Avatar_small
ch 说:
2022年3月04日 04:03

I am all that much satisfied with the substance you have said. I needed to thank you for this extraordinary article. xo slot

Avatar_small
amelia 说:
2022年5月08日 03:41

The data you have posted is exceptionally helpful. The destinations you have alluded was great. A debt of gratitude is in order for sharing... Prosper Grass Installation

Avatar_small
amelia 说:
2022年5月19日 00:12

A debt of gratitude is in order for the post and extraordinary tips..even I additionally surmise that diligent work is the most vital part of getting achievement.. slot

Avatar_small
amelia 说:
2022年5月19日 19:03

Awesome information! I as of late ran over your online journal and have been perusing along. I thought I would leave my first remark. I don't recognize what to say with the exception of that I have. Senior Care South Plainfield, NJ

Avatar_small
amelia 说:
2022年6月16日 04:27

Extraordinary overview, I'm certain you're getting an awesome reaction. Contraception Pills

Avatar_small
amelia 说:
2022年6月24日 01:28

I just couldn't leave your website before telling you that I truly enjoyed the top quality info you present to your visitors? Will be back again frequently to check up on new posts. landscape maintenance companies

Avatar_small
amelia 说:
2022年6月26日 01:02

A debt of gratitude is in order for sharing the post.. folks are universes best individual in every existences of individual..they need or must succeed to maintain needs of the crew. best free online courses with certificates


登录 *


loading captcha image...
(输入验证码)
or Ctrl+Enter