shopt -p shopt -u autocd shopt -u cdable_vars shopt -u cdspell shopt -u checkhash shopt -u checkjobs shopt -s checkwinsize shopt -s cmdhist shopt -u compat31 shopt -u compat32 shopt -u compat40 shopt -u shopt -u extdebug shopt -s extglob shopt -s extquote shopt -u failglob shopt -s force_fignore shopt -u globstar shopt -u gnu_errfmt shopt -s histappend shopt -u histreedit shopt -u histverify shopt -u hostcomplete shopt -u huponexit shopt -s interactive_comments shopt -u lastpipe shopt -u lithist shopt
假设你想要启用 extglob 选项,可以找到 shopt -s extglob 这一行。将这一行改为完整的文件路径形式,例如 shopt -s extglob 改为 . shopt 命令用于查看或修改 Bash 的选项设置。Bash 选项是一组用于控制 shell 行为的开关。使用 shopt 命令可以列出当前的选项设置,也可以启用或禁用特定的选项。 例如,要启用 extglob 选项,可以使用 shopt -s extglob。 例如,要禁用 extglob 选项,可以使用 shopt -u extglob。 要了解更多选项,请查阅 Bash 的官方文档或使用以下命令查看完整的选项列表:bashCopy codehelp shopt注意:shopt 命令只在当前的 shell 会话中生效,对于新的子 shell
---- 在shell中开启alias 使用shell内置命令shopt命令来开启alias扩展选项。 shopt是shell的内置命令,可以控制shell功能选项的开启和关闭,从而控制shell的行为 常用命令: Command Desc shopt -s opt_name Enable (set) opt_name . shopt -u opt_name Disable (unset) opt_name. shopt opt_name Show current status of opt_name. ---- 比如 查看同义词是否开启(交互模式下) [/xgj/gj]$shopt expand_aliases expand_aliases on shopt expand_aliases在交互式模式下 默认是打开的 ,在非交互式模式下是关闭的,但可以用可shopt来将其开启 shopt -s expand_aliases ---- 实际操作 在我们的项目中某个模块的双机启动脚本(root用户下操作),其中应用的启停使用了
使用 shopt shopt 命令还提供了一种让移动到其他目录更加容易的方法。当你使用 shopt 的 autocd 选项时,只需输入名称即可转到目录。 例如: $ shopt -s autocd $ www cd -- www /home/myacct/www $ pwd -P /var/www/html $ ~/bin cd -- /home/myacct /bin $ pwd /home/myacct/bin 在上面的第一组命令中,启用了 shopt 命令的 autocd 选项。 shopt 是 bash 内置命令,它有很多选项。这只是意味着你不必在要进入每个目录的名称之前输入 cd。 要查看 shopt 的其他选项,只需输入 shopt。
[simon@localhost ~]$ echo $0 bash [simon@localhost ~]$ ps -ef | grep '\-bash' | grep -v grep 判断登录式 shopt [root@localhost ~]# shopt login_shell login_shell on [root@localhost ~]# bash login_shell off 判断交互式和登录式的情况,一句话命令: [root@localhost ~]# echo $PS1;shopt login_shell [root@localhost ~]# echo $-;shopt [root@localhost ~]# su root [root@localhost ~]# echo $PS1;shopt login_shell [\u@\h \W]\$ login_shell shopt -q login_shell ; then # We're not a login shell ...
警告: 需要 bash 5.0+ 的 shopt -s compat44 。 示例函数: reverse_array() { # Usage: reverse_array "array" shopt -s extdebug f()(printf '%s\n ' "${BASH_ARGV[@]}"); f "$@" shopt -u extdebug } 示例用法: $ reverse_array 1 2 3 4 5 5 4 3 2 1 $ arr
/to/parentdir/{file1,file2,subdir/file3}; do printf '%s\n' "$file" done # Iterate recursively. shopt -s globstar for file in ~/Pictures/**/*; do printf '%s\n' "$file" done shopt -u globstar
当shopt选项cdable_vars打开时,如果dir在CDPATH及当前目录下均不存在,那么会把它当作变量,读取它的值作为要进入的目录。 参数 dir(可选):指定要切换到的目录。 关于cdable_vars shopt -s cdable_vars new_var='~/rumenz' cd new_var shopt -u cdable_vars 如果一个目录名称在环境中没有
当shopt选项cdable_vars打开时,如果dir在CDPATH及当前目录下均不存在,那么会把它当作变量,读取它的值作为要进入的目录。 参数 dir(可选):指定要切换到的目录。 关于cdable_vars shopt -s cdable_vars new_var='~/rumenz' cd new_var shopt -u cdable_vars 如果一个目录名称在环境中没有
警告: 需要 bash 5.0+ 的 shopt -s compat44 。 示例函数: reverse_array() { # Usage: reverse_array "array" shopt -s extdebug f()(printf '%s\n ' "${BASH_ARGV[@]}"); f "$@" shopt -u extdebug } 示例用法: $ reverse_array 1 2 3 4 5 5 4 3 2 1 $ arr
当 shopt 选项 cdable_vars 打开时,如果 dir 在 CDPATH 及当前目录下均不存在,那么会把它当作变量,读取它的值作为要进入的目录。 shopt -s cdable_vars 假设当前路径以及 CDPATH 没有名为 new_var 的目录。 new_var='~/Desktop' 尝试进入。 cd new_var 关闭选项。 shopt -u cdable_vars 注意 该命令是 bash 内建命令,相关的帮助信息请查看 help 命令。
cd blah cd - # Back to /tmp cd - # Back to 'blah' cd - # Back to /tmp cd - # Back to 'blah' ... 3) shopt set在之前的文章已经介绍过了,而shopt看起来与之相似。 只输入shopt会显示一系列选项: $ shopt cdable_vars off cdspell on checkhash off checkwinsize on cmdhist 从根本上说,似乎有一系列的bash(和其他shells)建立在sh之上,而添加shopt命令则为设置额外的shell选项提供了一种方式 但是我也不确定……如果你知道为什么,请告诉我。 这是设置方法: shopt -s extglob A="12345678901234567890" B=" ${A} " 现在来看看你是否能指出以下这些语句各自的功能: echo "B |
/to/parentdir/{file1,file2,subdir/file3}; do printf '%s\n' "$file" done # Iterate recursively. shopt -s globstar for file in ~/Pictures/**/*; do printf '%s\n' "$file" done shopt -u globstar
当shopt选项cdable_vars打开时,如果dir在CDPATH及当前目录下均不存在,那么会把它当作变量,读取它的值作为要进入的目录。 参数 dir(可选):指定要切换到的目录。 关于cdable_vars shopt -s cdable_vars new_var='~/rumenz' cd new_var shopt -u cdable_vars 如果一个目录名称在环境中没有
当shopt选项cdable_vars打开时,如果dir在CDPATH及当前目录下均不存在,那么会把它当作变量,读取它的值作为要进入的目录。 参数 dir(可选):指定要切换到的目录。 关于cdable_vars shopt -s cdable_vars new_var='~/rumenz' cd new_var shopt -u cdable_vars 如果一个目录名称在环境中没有
See bash(1) for more options HISTCONTROL=ignoreboth # append to the history file, don't overwrite it shopt check the window size after each command and, if necessary, # update the values of LINES and COLUMNS. shopt #shopt -s globstar # make less more friendly for non-text input files, see lesspipe(1) [ -x /usr/bin shopt -oq posix; then if [ -f /usr/share/bash-completion/bash_completion ]; then .
declare -rx HISTCONTROL="" declare -rx HISTIGNORE="" declare -rx HISTCMD declare -rx AUDIT_READY="yes" shopt -s histappend shopt -s cmdhist shopt -s histverify if shopt -q login_shell && [ -t 0 ]; then stty AUDIT_TAG=$(echo -n $AUDIT_STR | sha1sum |cut -c1-12) declare -x AUDIT_LASTHISTLINE="" set +o functrace shopt
shopt -oq posix; then #if [ -f /usr/share/bash-completion/bash_completion ]; then # . shopt -oq posix; then if [ -f /usr/share/bash-completion/bash_completion ]; then .
PROMPT_COMMAND=/etc/sysconfig/bash-prompt-default ;; esac fi # Turn on parallel history shopt -s histappend history -a # Turn on checkwinsize shopt -s checkwinsize [ "$PS1" = "\\s-\\v\\\ shopt -q login_shell ; then # We're not a login shell # Need to redefine pathmunge, it get's undefined
: event not found 上面这种情况是因为我们的系统没有开启通配符功能,我们执行下面的命令开启通配符功能先: shopt -s extglob 查看通配符功能是否开启,on表示已经开启 shopt