Linux Shell整理小知识
2022/8/12 5:23:04
本文主要是介绍Linux Shell整理小知识,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
介绍两个命令
1. shopt
- shell option, 即shell的一些选项设置
[[email protected] ~]# shopt autocd off cdable_vars off cdspell off checkhash off checkjobs off checkwinsize on cmdhist on compat31 off ...
- 其用法如下
[[email protected] ~]# 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
- 使得shell支持额外的逻辑符,这里我用的主要是非符号
!
。 - 没找到在哪看shopt选项的说明,先找了别人博文总结的说明
?(pattern-list) 匹配给定模式零或一次 *(pattern-list) 匹配给定模式零次或多次 +(pattern-list) 匹配给定模式一次或多次 @(pattern-list) 匹配给定模式之一 !(pattern-list) 匹配除了给定的模式
- 用法:
mv !(a|dir) dir # 将当前目录内除了a的所有文件移入dir文件夹 rm !(*.txt) # 删掉除了txt后缀的全部文件
这篇关于Linux Shell整理小知识的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!
- 2024-03-30[译]漫画SELinux概念
- 2024-03-29linux 移动文件
- 2024-03-28linux .so file
- 2024-03-28Linux 磁盘管理
- 2024-03-28Linux学习笔记(十三)磁盘管理(一):磁盘分区
- 2024-03-26linux 创建 文件
- 2024-03-25使用SecureCRT对Linux vim进行颜色设置
- 2024-03-202019-2020-12 20199317 《Linux内核原理与分析》 第十二周作业
- 2024-03-20Linux运维的第二周总结
- 2024-03-13how to count number of directories in linux