系统相关
首页 > 系统相关> > Linux Shell整理小知识

Linux Shell整理小知识

作者:互联网

介绍两个命令

1. shopt

[root@localhost ~]# shopt
autocd          off
cdable_vars     off
cdspell         off
checkhash       off
checkjobs       off
checkwinsize    on
cmdhist         on
compat31        off
...

[root@localhost ~]# 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.

2. extglob

?(pattern-list)		匹配给定模式零或一次
*(pattern-list)		匹配给定模式零次或多次
+(pattern-list)		匹配给定模式一次或多次
@(pattern-list)		匹配给定模式之一
!(pattern-list)		匹配除了给定的模式
mv !(a|dir) dir # 将当前目录内除了a的所有文件移入dir文件夹
rm !(*.txt)     # 删掉除了txt后缀的全部文件

标签:shell,off,pattern,知识,list,each,Shell,Linux,shopt
来源: https://www.cnblogs.com/AikN/p/16576016.html