Linux retains several files and deletes others

Source: Internet
Author: User

Linux retains several files and deletes others

The set Option and shopt option are two different groups of content. You can use set-o and shopt-p to view all the open and closed entries of the two groups respectively. By default, some are open and some are closed. The shopt options will increase with the bash version update. The basic operations related to shopt are as follows:

# Shopt-p listing all options
# Shopt-s: list all open options
# Shopt-s extglob enable extglob Option
# Shopt-u list all disabled options
# Shopt-u extglob disable extglob Option

Description:
Cdspell when a cd directory is entered, if the directory name is accidentally wrong, a letter is wrong or missing, you can also enter the directory.
A hidden file starting with a dot in dotglob can be represented as a wildcard, just like other files.
Extglob can use rm! (* Jpg) to delete all file names that do not end with jpg. You can also use rm * @ (jpg | png) to represent "or". Of course, there are other .....
When using bash, you need to familiarize yourself with these options and find the settings that suit your taste.

A total of 9 files, except for retaining files 1, 2, and 3, are deleted.
[Report @ localhost ~ /Tmp] $ ls
1 2 3 4 5 6 7 8 9
[Report @ localhost ~ /Tmp] $ shopt-s extglob
[Report @ localhost ~ /Tmp] $ rm-rf! (1 | 2 | 3)
[Report @ localhost ~ /Tmp] $ ls
1 2 3
[Report @ localhost ~ /Tmp] $ shopt-u extglob

This article permanently updates the link address:

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.