[英]How can I output a value to a specific line in Bash shell?
How can I print a value to specific line in Bash shell?如何将值打印到 Bash shell 中的特定行?
(For example, I would like to print a value up to the 10th line.) (例如,我想打印一个直到第 10 行的值。)
It's not specific to bash
but you can use tput cup YX
to set the cursor position:它不是特定于
bash
但您可以使用tput cup YX
设置 cursor position:
tput sc # save cursor position
tput cup 10 0
echo -n "hello"
tput rc # restore cursor position
Yo can try to show line numbers of the files, and grep it for the line:哟可以尝试显示文件的行号,并 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.