Wildcard characters, metacharacters, escape characters in Linux

Source: Internet
Author: User

Tagged with: Shell wildcard characters Linux

Wildcard characters, metacharacters, escape characters in Linux

    • Wildcard OFDM character escapes in Linux
      • The composition of the shell command
        • Wildcard characters
        • Metacharacters Meta
        • Escape character
      • Example
      • Reference

The composition of the shell command

Each character in each Linux command is one of the following two types:
-Literal: Plain plain text
-Reserved word: Wildcard, metacharacters, escape character

Wildcard characters

Wildcards are handled by the shell (not by the command statements involved, but we are not aware of these wildcard characters in the shell commands), it will only appear in the "Parameters" of the command (it is not in the command name, nor on the operator). when the shell encounters a wildcard in parameters, the shell treats it as a path or file name to search for possible matches on the disk: If a matching match exists, the substitution (path extension) is performed, otherwise the wildcard is passed as a normal character to the command, which is then processed by the command. in short, a wildcard is actually a kind of path extension that the shell implements. After the wildcard is processed, the shell completes the reorganization of the command before continuing with the reorganized command until the command is executed.
Wildcard wildcards regular the expression looks very much the same, but in fact, it is only the special character of the shell.

    • *: Match 0 or more characters
    • ?: matches any one character
    • [list]: matches any single character in the list
    • [!list]: matches any single character in a non-list
    • [a1-a3]: Matches any one of the characters between A1 and A3, such as 0-9,a-z
    • {string1,string2,string3...}: Match string1, or string2 or ... One of the strings
Metacharacters Meta
    • IFS: Consists of <space><tab><enter> one of three, used to split word in command line
    • CR: <enter> generated, used to end a command line
    • =: Assign Value
    • $: Variable substitution
    • >: stdout
    • <: stdin
    • |: Pipeline Command
    • &: Redirect file descriptor, or place commands in the background
    • `: Used to replace
    • (): Place the command in nested Subshell, or for operation or command substitution
    • {}: Executes the command in the Non-named function, or is used to define the scope of the variable substitution
    • ;: At the end of a command, ignore its return value, continue to perform a scare command
    • &&: At the end of a command, if the return value is true, proceed to the next command
    • ||: At the end of a command, if the return value is false, proceed to the next command
    • !: Executes a command from the history list
Escape character

The escape character is used when we want to close the META function.

    • (single quote) hard quote, where all meta-quote are closed.
    • "(double quotes) Soft quote, most of the meta-metadata in soft quote is closed, but some meta functions (such as $) are preserved.
    • \(backslash) escape, only a single meta is closed immediately after the escape (caret).

Dquote is not closed in meta: $ , anti-quote ` , backslash \ .

? ~ LS- Dp*# files that start with PPictures Projects public? ~ A=b CThe #<space> was not closed as IFS processing. Zsh:command not found:c? ~ a="B C" #<space> is turned off in ", use as normal character? ~Echo $AB C? ~ a="B dquote> cdquote>" #<enter> is turned off in ", used as a normal character, because command line does not get the CR character, so enter the second shell prompt (denoted by the > symbol). ? ~Echo $ABc? ~ a=b\ C# \ Make <space> function off, only when normal spaces are used? ~Echo ' $A ' # $ in squote function off, only for literal$A? ~Echo "$A" # $ in dquote function not closed for meta useB C? ~Echo\$A$A? ~


Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

Wildcard characters, metacharacters, escape characters in Linux

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.