[英]How can I output a value to a specific line in Bash shell?
如何將值打印到 Bash shell 中的特定行?
(例如,我想打印一個直到第 10 行的值。)
它不是特定於bash
但您可以使用tput cup YX
設置 cursor position:
tput sc # save cursor position
tput cup 10 0
echo -n "hello"
tput rc # restore cursor position
喲可以嘗試顯示文件的行號,並 grep 它為該行:
$ cat test
A
B
C
$ cat test -n |grep ^" 2"
2 B
$ cat test2
A
B
C
D
E
F
$ cat test2 -n |grep ^" 4"
4 D
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.