Shell built-in command shopt extglob options

Source: Internet
Author: User

Introduction

The shopt command allows you to set optional parameters for the shell.

shopt [-PSU] [optname ...]

-S turns on an option.

-U turns off an option.

-p lists all the options that can be set.

Extglob Options

If the EXTGLOB option is turned on, the shell will enable pattern matching. Reference to Shell pattern matching

See if the EXTGLOB option is on (default is OFF)

$ shopt Extglobextglob off

Turn on the EXTGLOB option

$ shopt-s Extglob

Check whether the EXTGLOB option is turned on at this

$ shopt extglob   Extglob on

Turn off the EXTGLOB option

$ shopt-u Extglob
Instance

Move all files and directories under the directory to the backup directory.

3 files and two directories in the current directory

$ lsdir1  dir2  file1  file2  file3

Create a new backup directory

$ mkdir-p Backup

Move other files and directories other than the backup directory to the backup directory

$ mv! (Backup) backup/

View Results

$ lsbackup$ ls backup/dir1  dir2  file1  file2  file3

Delete all files or directories at the beginning of the file in the current directory

$ lsbackup  dir1  dir2  file1  file2  file3$ rm-rf file[1-3]$ lsbackup  dir1  Dir2

Move in addition to the Dir1 directory and the File1 file to the backup directory

$ mv! (dir1|file1|backup) backup/$ lsbackup  dir1  file1$ ls backup/dir2  file2  file3

Other requirements also need to be extrapolate in combination with shell pattern matching.

Shell built-in command shopt extglob options

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.