11-linux Basic Primer (ix)-linux wildcard

Source: Internet
Author: User

I. Overview

The wildcards regular of the Linux wildcard is not the same, so the meaning of the representation is also very different. Wildcard characters are typically used for user command-line bash environments, while Linux regular expressions are used for grep, SED, awk scenarios.

Symbol

Representative meaning

*

All (0 to more) characters

Any one character

Delimiters for successive different commands

#

Configuration file comments

|

Pipeline

~

Home directory of the current user

-

The path that was last

$

The symbol to be added before the variable

/

The path separates the symbol, also is the root meaning

> or 1>

Redirect (overwrite original data)

>>

Append Redirect (append content file trailer)

<

Input redirection (Xargs, TR)

<<

Append input redirection (CAT)

Single quotation mark: Do not have variable substitution function, the output is WYSIWYG

"

Double quotes: variable substitution function, output after parsing variables, no quotation marks equivalent to double quotes, common double quotes

`

Anti-quotation mark (tab top button): Two "in the middle of the command, will be executed first, equivalent to $ ()

{}

The middle is the command block combination or the content sequence

!

"Non" (not) in logical operation

&&

and (and): When the execution of the current instruction succeeds, the following instruction is executed

||

or (OR): When the execution of the current instruction fails, the following command is executed

..

Top level Directory

.

Current directory

Ii. Some examples of the use of wildcard characters

1, * No.

[Email protected] ~]# mkdir test

[[Email protected] ~]# CD test

[email protected] test]# Touch test.sh zhangyujia.sh zhangyj.sh

[[email protected] test]# ls

test.sh zhangyj.sh zhangyujia.sh

[[email protected] test]# ls *.sh all files ending with #在当前文件夹查询以. Sh

test.sh zhangyj.sh zhangyujia.sh

[email protected] test]# Touch zhangyujia.txt

[[email protected] test]# LS * #列出当前文件夹的所有文件

test.sh zhangyj.sh zhangyujia.sh Zhangyujia.txt

2,? No.

[email protected] test]# ls????. SH #代表四个字符

test.sh

[email protected] test]# Touch a.sh

[email protected] test]# ls?. SH #代表一个字符

a.sh

Attention:? Matches only one character.

3,; The delimiter between two commands

[Email protected] test]# Ls;ls

a.sh test.sh zhangyj.sh zhangyujia.sh zhangyujia.txt

a.sh test.sh zhangyj.sh zhangyujia.sh zhangyujia.txt

4. {} Content Sequence example

#按需生成你想要的东西

[[email protected] test]# echo zhangyujia{1,2,3}

Zhangyujia1 zhangyujia2 Zhangyujia3

[[email protected] test]# echo zhangyujia{1..5}

Zhangyujia1 zhangyujia2 zhangyujia3 zhangyujia4 zhangyujia5

[Email protected] test]# echo zhangyujia{a. Z

ZHANGYUJIAA Zhangyujiab zhangyujiac zhangyujiad zhangyujiae zhangyujiaf zhangyujiag Zhangyujiah zhangyujiai zhangyujiaj Zhangyujiak zhangyujial zhangyujiam Zhangyujian zhangyujiao zhangyujiap zhangyujiaq zhangyujiar zhangyujias zhangyujiat Zhangyujiau zhangyujiav Zhangyujiaw Zhangyujiax zhangyujiay Zhangyujiaz

#备份文件

[[email protected] test]# CP A.txt{,.bak}

[[email protected] test]# LS A *

a.sh a.txt A.txt.bak

#创建文件夹

[Email protected] test]# mkdir/data/{1,2}/data-p

[Email protected] test]# tree/data/

/data/

├──1

│└──data

└──2

└──data

4 directories, 0 files

Welcome Attention
Sina Weibo: https://weibo.com/yougazhang0506
Public platform: Zhang Yujia

My site: http://www.zhangyujia.cn
51CTO Blog: http://blog.51cto.com/11099293
csdn Blog: http://blog.csdn.net/u013260195
github:https://github.com/zhangyujia0506/


11-linux Basic Primer (ix)-linux wildcard

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.