WILDCARDS

WILDCARD "?": its meaning is one character in Linux.

Example,

[root@localhost root]# ls cool?

cool1 cool0 coolA coolz

ð It is showing the files, which file's name is started with "cool" and next one character may be a, b, c ...., z or 0, 1, 2, ... 9 etc.

Example,

[root@localhost root]# ls local??

local12 localab

Example,

[root@localhost root]# ls cool.?

cool.a cool.1 cool._

ð Showing those files’ name while the extension of each file is single character.

Example,

[root@localhost root]# ls ?.?

a.c b.c j.c

WILDCARD "*": its meaning is more characters in Linux.

Example,

[root@localhost root]# ls *open

firstopen secondopen oldopen

ð Showing those files’ name while last four characters of files are "open".

Example,

[root@localhost root]# ls *mail*

sumonmail1 sumonmail2 azgarmail1

ð Showing those files’ name which has four characters, "mail" is in middle.

[root@localhost root]# ls sumon.*

sumon.sh sumon.cpp sumon.c

ð Showing those files’ name which is "sumon" and can be any extension.

Example,

[root@localhost root]# ls *.*

ð It shows all files those have an extension from the current directory.

[root@localhost root]# ls *

ð It shows all files from the current directory.

WILDCARD "[ ]":

Consider, in /root directory has following files and we can select different file or files to access by using wildcard “-”.

[root@localhost root]# ls

edit1 edit2 edit3 ... ... ... ... edit9

edita editb editc ... ... ... ... editz

edit$ edit@ edit_ ... ... ... ...

Example,

[root@localhost root]# ls edit[123]

edit1 edit2 edit3

Example,

[root@localhost root]# ls edit[^123]

ð It shows all files except edit1, edit2, and edit3.

Example,

[root@localhost root]# ls edit[0-9]

edit0 edit1 edit2 edit3 edit4 edit5 edit6 edit7 edit8 edit9

Example,

[root@localhost root]# ls edit[a-z]

edita editb editc ... ... ... ... editz

Example,

[root@localhost root]# ls edit[^0-9 a-z]

edit$ edit@ edit_

Note: We can also utilize this above wildcards (? , * , [ ]) with other commands, such as cp, mv, rv etc