Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/macos/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Macos 从bash脚本中清除当前行上的所有文本_Macos_Bash_Terminal - Fatal编程技术网

Macos 从bash脚本中清除当前行上的所有文本

Macos 从bash脚本中清除当前行上的所有文本,macos,bash,terminal,Macos,Bash,Terminal,如何从bash脚本中生成ctrl u Ie我想删除一行中光标左侧的所有字符,并将光标放在第0列 解决方法可能是打印\r,然后清除光标右侧的内容 我不想清除整个终端屏幕 更新: 我使用的解决方案(在PHP中): 基本上你可以这样做: while :; do # an infinite loop just for demonstration echo "$RANDOM" # print your stuff here sleep 0.2 tput cuu1 # move cu

如何从bash脚本中生成ctrl u

Ie我想删除一行中光标左侧的所有字符,并将光标放在第0列

解决方法可能是打印
\r
,然后清除光标右侧的内容

我不想清除整个终端屏幕

更新:

我使用的解决方案(在PHP中):


基本上你可以这样做:

while :; do # an infinite loop just for demonstration
    echo "$RANDOM" # print your stuff here
    sleep 0.2
    tput cuu1 # move cursor up by one line
    tput el # clear the line
done

有关详细信息,请使用
man tput
。要查看功能列表,请使用
人工终端

while :; do # an infinite loop just for demonstration
    echo "$RANDOM" # print your stuff here
    sleep 0.2
    tput cuu1 # move cursor up by one line
    tput el # clear the line
done

有关详细信息,请使用
man tput
。要查看功能列表,请使用
man terminfo

我在这里找到了一个有效的答案:因此我想我可以将我的问题删除为重复:-pposible duplicate of我在这里找到了一个有效的答案:因此我想我可以将我的问题删除为重复:-pposible duplicate of