我試圖改變終端中的回顯行的文本,\ r適用於我,但不是當我把它放在.sh文件中。我想運行一個.sh文件,以1秒爲間隔更改回顯行(不要問爲什麼)。當我做如何在迴音線上書寫?
echo -ne 'hello\r'
sleep 1
echo -ne 'bye\r'
它
-ne hello
-ne bye
輸出我怎麼acheive我的目標是什麼?
我試圖改變終端中的回顯行的文本,\ r適用於我,但不是當我把它放在.sh文件中。我想運行一個.sh文件,以1秒爲間隔更改回顯行(不要問爲什麼)。當我做如何在迴音線上書寫?
echo -ne 'hello\r'
sleep 1
echo -ne 'bye\r'
它
-ne hello
-ne bye
輸出我怎麼acheive我的目標是什麼?
的重要部分:
- Position the Cursor:
\033[<L>;<C>H
Or
\033[<L>;<C>f
puts the cursor at line L and column C.
- Move the cursor up N lines:
\033[<N>A
- Move the cursor down N lines:
\033[<N>B
- Move the cursor forward N columns:
\033[<N>C
- Move the cursor backward N columns:
\033[<N>D
- Clear the screen, move to (0,0):
\033[2J
- Erase to end of line:
\033[K
- Save cursor position:
\033[s
- Restore cursor position:
\033[u
所以像:
echo -ne "\033[50D"
echo -ne "\033[K"
你是否有機會使用busybox?看起來你有一個不兼容的回聲。另外,你的例子應該是\ r不是\ n。 –
哦是的,我的意思是\ r,我會修復 – Zack