Linux file wildcard and command line extension

Source: Internet
Author: User
Tags lowercase printable characters uppercase letter

* match 0 or more characters

? Match any single character

~ Current User home directory

~mage User Mage home directory

~+ Current working directory

~- Previous working directory

[0-9] match number range

[A-z]: Letters

[A-z]: Letters

[Wang] matches any one of the characters in the list

[^wang] matches characters other than all characters in the list

Other special characters

\ Skip symbol: revert "special character or wildcard" to a normal character

| Pipe: The definition of two piping commands;

; Continuous Instruction Release delimiter: (Note!) Not the same as pipeline command)

& Job Control: Turn the instruction into a background work

! the meaning of "not" in the sense of logical operation

Pre-defined character class: Man 7 glob

[:d igit:]: Any number, equivalent to 0-9

[: Lower:]: Any lowercase letter

[: Upper:]: Any uppercase letter

[: Alpha:]: Any case letter

[: Alnum:]: any number or letter

[: Blank:]: horizontal white space character

[: Space:]: Horizontal or vertical whitespace characters

[:p UNCT:]: Punctuation

[:p rint:]: Printable characters

[: Cntrl:]: Control (nonprinting) character

[: Graph:]: Graphic character

[: Xdigit:]: hexadecimal character

1. Display all files or records in the/test directory that begin with L with a lowercase letter ending with at least one digit in the middle

Method 1

#ls-D/test/l*[0-9]*[[:lower:]]

/test/ll4898ufjaj/test/ll4ufjaaj/test/ll4ufjaj/test/ll4ufjajc

Method 2

#ls-D/test/l*[[:d Igit:]]*[[:lower:]]

/test/ll4898ufjaj/test/ll4ufjaaj/test/ll4ufjaj/test/ll4ufjajc

Method 3

#ls-D/test/l*[^a-za-z]*[[:lower:]]

/test/ll4898ufjaj/test/ll4ufjaaj/test/ll4ufjaj/test/ll4ufjajc

2. display files or directories that begin with any digit in the/test directory and end with a non-digit

Method 1

#ls-D/test/[[:d Igit:]]*[[:alpha:]]

/test/112prueiruenjfdkeieji88.conf

Method 2

#ls-D/test/[0-9]*[^0-9]

/test/112prueiruenjfdkeieji88.conf

Method 3

#ls-D/test/[[:d Igit:]]*[a-za-z]

/test/112prueiruenjfdkeieji88.conf

3, display/test/directory with a non-letter beginning, followed by a letter and any other arbitrary length of any character file or directory

Method 1

#ls-D/test/[0-9][[:alpha:]]*

/test/0ll4ufjajbb007

Method 2

#ls-D/test/[^[:alpha:]][[:alpha:]]*

/test/0ll4ufjajbb007

Method 3

#ls-D/test/[^a-za-z][a-za-z]*

/test/0ll4ufjajbb007

4. Display all the numbers in the/test/directory starting with RC, followed by 0-6, other files or directories of any character

#ls-D/test/rc[0-6]*

/test/rc1rjeirie/test/rc2jidf9fdjfd/test/rc556kkfjdjfkd

5. Display all files or directories ending with. D in the/etc directory

#ls-D/ETC/*.D

/etc/bash_completion.d/etc/logrotate.d/etc/rc1.d/etc/rwtab.d

/etc/chkconfig.d/etc/lsb-release.d/etc/rc2.d/etc/sane.d

/etc/cron.d/etc/makedev.d/etc/rc3.d/etc/setuptool.d

/etc/depmod.d/etc/modprobe.d/etc/rc4.d/etc/statetab.d

6. Display the/test directory, all the. conf ends, and the files or directories that start with m,n,r,p

#ls-D/test/[mnrp]*.conf

/test/mrueiruenjfdkeieji88.conf/test/prueiruenjfdkeieji88.conf

/test/nrueiruenjfdkeieji88.conf/test/rrueiruenjfdkeieji88.conf

7. Show only hidden files and directories under/root

#ls-D/root/. [^.] *

/root/.abrt/root/.cshrc/root/.gtk-bookmarks/root/.nautilus

/root/.bash_history/root/.dbus/root/.gvfs/root/.pulse

/root/.bash_logout/root/.esd_auth/root/.history/root/.pulse-cookie

/root/.bash_profile/root/.gconf/root/. Iceauthority/root/.ssh

8. Show only hidden directories under/root

#ls-D/root/. [^.] */

/root/.abrt//root/.dbus//root/.gnote//root/.local//root/.ssh/

/root/.cache//root/.gconf//root/.gnupg//root/.nautilus/

/root/.config//root/.gnome2//root/.gvfs//root/.pulse/

9. Show only non-hidden directories under/etc

#ls-D/etc/[^.] */

/etc/abrt//etc/gcrypt//etc/ntp//etc/reader.conf.d/

/etc/acpi//etc/gdm//etc/obex-data-server//etc/redhat-lsb/

Bracket extension: {}

Simplified form of repeating strings

Semicolons separate specific content

#touch file{1,3,5}; LS file*

File1 File3 File5

{Start value: End Value}

#echo {0..10}

0 1 2 3 4 5 6 7 8 9 10

#echo {A}. Z

A b c d e F g h i j k l m n o p q R S t u v w x y Z

#echo {A}. Z

A B C D E F G H I J K L M N O P Q R S T U V W X Y Z

#echo {A}. Z

A ' _ ^] [Z

{format: Maximum value: Number of steps}

#echo {000..10..1}

000 001 002 003 004 005 006 007 008 009 010


This article is from the "Golden Mystery" blog, please be sure to keep this source http://191226139.blog.51cto.com/211244/1981393

Linux file wildcard and command line extension

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.