linux内建命令/内部命令之shopt

本文介绍了Linux内建命令shopt的作用,用于在shell中动态修改选项,如开启cdspell允许拼写错误,以及列举了一系列可被修改的shell选项。
摘要由CSDN通过智能技术生成

1.shopt介绍

linux内建命令shopt允许shell在空闲时修改shell选项,它经常出现在启动文件中。但是,在一般脚本中也常出现,不过需要在版本2之后的bash中才支持。

2.样例

-->shopt用法

命令:

help shopt

[root@elasticsearch ~]# help shopt
shopt: shopt [-pqsu] [-o] [optname ...]
    Set and unset shell options.
    
    Change the setting of each shell option OPTNAME.  Without any option
    arguments, list all shell options with an indication of whether or not each
    is set.
    
    Options:
      -o	restrict OPTNAMEs to those defined for use with `set -o'
      -p	print each shell option with an indication of its status
      -q	suppress output
      -s	enable (set) each OPTNAME
      -u	disable (unset) each OPTNAME
    
    Exit Status:
    Returns success if OPTNAME is enabled; fails if an invalid option is
    given or OPTNAME is disabled.
[root@elasticsearch ~]# 

样例:

[root@elasticsearch ~]# shopt -s cdspell      #设置使用cd命令时,允许产生少量的拼写错误
[root@elasticsearch ~]# cd /hpme              #应该是"/home"
/home
[root@elasticsearch home]# pwd
/home                                         #正常进入/home目录,说明拼写错误被纠正了
[root@elasticsearch home]# 

-->被允许修改的shell选项

[root@elasticsearch home]# shopt
autocd         	off
cdable_vars    	off
cdspell        	on               #常用
checkhash      	off
checkjobs      	off
checkwinsize   	on
cmdhist        	on
compat31       	off
compat32       	off
compat40       	off
compat41       	off
direxpand      	off
dirspell       	off
dotglob        	off             #常用
execfail       	off
expand_aliases 	on
extdebug       	off
extglob        	off             #常用
extquote       	on
failglob       	off
force_fignore  	on
globstar       	off
gnu_errfmt     	off
histappend     	on
histreedit     	off
histverify     	off
hostcomplete   	on
huponexit      	off
interactive_comments	on
lastpipe       	off
lithist        	off
login_shell    	on
mailwarn       	off
no_empty_cmd_completion	off
nocaseglob     	off
nocasematch    	off
nullglob       	off               #常用
progcomp       	on
promptvars     	on
restricted_shell	off
shift_verbose  	off
sourcepath     	on
syslog_history 	off
xpg_echo       	off
[root@elasticsearch home]# 

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

小黑要上天

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值