Bash文字绝对定位 [英] Bash text absolute positioning

查看:56
本文介绍了Bash文字绝对定位的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何对输出进行绝对定位?与Linux首次启动时类似,您会看到以下内容:

How can you do absolute positioning of output? Very similar to like when Linux first boots and you see the following:

Starting process blah blah blah                              [   OK   ]

推荐答案

您可以在/etc/init.d中的许多Linux发行版中看到用于生成那些 [OK] 的代码./功能

You can see the code used to produce those [ OK ] in many Linux distributions in /etc/init.d/functions

$ grep echo_ /etc/init.d/functions
echo_success() {
echo_failure() {
echo_passed() {
echo_warning() {
$

经检查,您将看到这些函数使用 ANSI转义序列.

Upon inspection, you will see that those function use ANSI escape sequences.

echo_success() {
  [ "$BOOTUP" = "color" ] && $MOVE_TO_COL
  ...
  return 0
}

MOVE_TO_COL="echo -en \\033[${RES_COL}G"

这篇关于Bash文字绝对定位的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆