明确的问题是:

明确的问题是:

我尝试显示命令行的帮助页面unset,结果得到以下输出:

无需手动输入取消设置

我懂了这个问题但是,由于它们很相似,因此它不能解决这个问题。事实上,这个问题已经通过使用此 cmd 安装一些软件包来解决:

sudo apt-get install manpages-posix manpages-posix-dev

因此,我尝试做同样的事情;除了通过 unset 修改 posix,所以我这样做:

sudo apt-get install manpages-unset

结果是:

无法找到软件包 manpages-unset

明确的问题是:

如何显示未设置的手册

答案1

由于和setunsetshell 内建命令,您需要使用help命令来获取它们的详细帮助:

$ help unset
unset: unset [-f] [-v] [-n] [name ...]
Unset values and attributes of shell variables and functions.

For each NAME, remove the corresponding variable or function.

Options:
  -f    treat each NAME as a shell function
  -v    treat each NAME as a shell variable
  -n    treat each NAME as a name reference and unset the variable itself
    rather than the variable it references

Without options, unset first tries to unset a variable, and if that fails,
tries to unset a function.

Some variables cannot be unset; also see `readonly'.

Exit Status:
Returns success unless an invalid option is given or a NAME is read-only.

答案2

set并且unset不是第三方二进制文件。它们是Shell 内置命令。这意味着它们位于 shell 的“内部”。如果您使用的是 bash,则可以运行type来检查它。

$ type set
set is a shell builtin
$ type unset
unset is a shell builtin

引自 Bash Reference:

内置命令包含在 shell 本身中。当内置命令的名称用作简单命令的第一个字时(请参阅 3.2.1 简单命令),shell 会直接执行该命令,而无需调用其他程序。内置命令对于实现无法或不方便使用单独实用程序实现的功能必不可少。

要查找手册,只需unset运行man bash。或者您可以查找信息这里

答案3

unset命令shell 内建的bash- 所以它在的手册页bash
此外,你还可以获得简短描述命令help- 通常help unset可以解释您的需要。

要找到它手册页,手动在“SHELL BUILTIN COMMANDS”部分中找到它,或者搜索unset \[

或者,如果您愿意,对于这种特殊情况,可以使用一个命令:

man bash | less -p 'unset \['


man bash“SHELL BUILTIN COMMANDS”中取消设置的部分:

  unset [-fv] [-n] [name ...]
           For each name, remove the corresponding variable  or  func‐
           tion.   If  the  -v  option is given, each name refers to a
           shell variable, and that variable  is  removed.   Read-only
           variables  may not be unset.  If -f is specified, each name
           refers to a shell function, and the function definition  is
           removed.  If the -n option is supplied, and name is a vari‐
           able with the nameref attribute, name will be unset  rather
           than  the  variable it references.  -n has no effect if the
           -f option is supplied.  If no options  are  supplied,  each
           name  refers to a variable; if there is no variable by that
           name, any function with that name  is  unset.   Each  unset
           variable or function is removed from the environment passed
           to subsequent commands.  If any of COMP_WORDBREAKS, RANDOM,
           SECONDS, LINENO, HISTCMD, FUNCNAME, GROUPS, or DIRSTACK are
           unset, they lose their special properties, even if they are
           subsequently  reset.  The exit status is true unless a name
           is readonly.

来自 Ubuntu 14.4 上 bash 4.3 的手册页

答案4

参考SS64



操作 shell 变量和函数。
句法
      设置 [--abBCefhHkmnpPtuvx] [-o 选项] [参数...]

如果未提供任何选项或参数,set 将显示所有 shell 变量和函数的名称和值,并按当前语言环境排序,格式可重复用作输入。提供选项后,它们将设置或取消设置 shell 属性。
选项

使用 + 而不是 - 将导致选项被关闭。

   -a 标记已修改或已创建的变量以供导出。-o allexport     

   -b 使已终止的后台作业的状态为
       立即报告,而不是在打印之前
       下一个主要提示。-o 通知

   -B shell 将执行括号扩展。
       默认情况下此选项处于启用状态。-o braceexpand

   -C 防止使用 `>'、`>&' 进行输出重定向,
       和“”覆盖现有文件。-o noclobber

   -e 如果简单命令以非零状态退出,则立即退出,除非
       失败的命令是until或while循环的一部分,是
       if 语句、&& 或 || 列表的一部分,或者命令的返回状态
       正在使用 ! 反转。-o errexit

   -f 禁用文件名生成(通配符)。 -o noglob

   -h 定位并记住(哈希)命令
       执行。此选项默认启用。-o hashall

   -H 启用“!”样式历史替换
       对于交互式 shell,此选项默认处于启用状态。-o histexpand

   -k 所有以赋值语句形式出现的参数都是
       放置在命令的环境中,而不仅仅是那些
       位于命令名称之前。-o 关键字

   -m 作业控制已启用。 -o 监视

   -n 读取命令但不执行它们;这可以使用
       检查脚本的语法错误。
       交互式 shell 会忽略此选项。-o noexec

   -o 选项名称
          设置与‘option-name’对应的选项
          `选项名称'列于上方和下方(以粗体显示)      

          emacs:使用 emacs 风格的行编辑界面。
          history :启用命令历史记录,
                      在交互式 shell 中此选项默认处于启用状态。
          ignoreeof :交互式 shell 在读取 EOF 时不会退出。
          posix:改变 Bash 的行为以匹配 POSIX 1003.2 标准。
          vi :使用 vi 风格的行编辑界面。

   -p 开启特权模式。在此模式下,
       $BASH_ENV 和 $ENV 文件未被处理,
       shell 函数不能从环境中继承,
       如果 SHELLOPTS 变量出现在环境中,则会被忽略。
       如果 shell 启动时的有效用户(组)id 不等于
       真实用户(组)ID,并且未提供 -p 选项,则这些操作
       并将有效用户 ID 设置为真实用户 ID。
       如果在启动时提供了 -p 选项,则有效用户
       id 不会被重置。关闭此选项会导致有效
       用户和组 ID 设置为真实用户和组 ID。
         -o 特权

   -P 如果设置,则执行命令时不要遵循符号链接。
       而是使用物理目录。-o physical

   -t 读取并执行一个命令后退出。 -o onecmd

   -u 执行时将未设置的变量视为错误
       参数扩展。将写入一条错误消息
       到标准错误,并且非交互式 shell 将退出。-o nounset

   -v 在读取 shell 输入行时将其打印出来。 -o verbose

   -x 打印简单命令及其参数的踪迹
       在它们扩展之后和执行之前。-o xtrace

   -- 如果此选项后面没有参数,则位置参数未设置。
       否则,位置参数将设置为参数,
       即使其中一些以“-”开头。

   - 表示选项的结束,导致所有剩余的参数
       分配给位置参数。‘-x’ 和 ‘-v’
       选项已关闭。如果没有参数,则位置参数
       保持不变。

例子

将变量“mydept”设置为“Sales”:
 我的部门=销售

要使更改永久生效:

 导出我的部门

相关内容