gpt4 book ai didi

linux - 这是 bash 中的错误吗?(向上箭头)

转载 作者:IT王子 更新时间:2023-10-29 00:12:08 25 4
gpt4 key购买 nike

众所周知,按向上箭头键可以显示历史命令,但我发现以空格开头的命令不会显示在“向上箭头”的历史记录中:

$ls

$(按向上箭头键)

bash 将显示:

$ls

但是:

$ps

$ ls(注意这个命令以空格开头)

现在我按向上箭头键,它会显示'ps'而不是'ls':

$ps

这是 bash 中的错误还是特定功能?:)

最佳答案

来自 bash(1):

   HISTCONTROL
A colon-separated list of values controlling how
commands are saved on the history list. If the list
of values includes ignorespace, lines which begin with
a space character are not saved in the history list.

这是一项有意为之的功能,可让您防止将带有密码或其他私有(private)数据的命令保存到磁盘。 (它不会将它排除在 ps(1) 进程列表之外。)

关于linux - 这是 bash 中的错误吗?(向上箭头),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9961291/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com