$ echo 'This is a semicolon the quotes hide it from the shell.'.Turning off the special meaning of metacharacters by surrounding them with single or double quotes, or putting a backslash in front of them: part – it’s all treated as one word because neither letters nor periods are meta-characters to the shell.) (The shell does not split the cd away from the. The unquoted string one two contains three tokens, because the shell treats the metacharacter semicolon specially and splits the string into three pieces: the word one, the meta-character, and the word two. The unquoted two-word string one two contains two (blank-separated) tokens. Token or word A non-blank piece of the command line that can’t be further separated into other tokens by the shell. You can usually turn a metacharacter into an ordinary non-special character by quoting it. The symbol asterisk (or star) * is a metacharacter, and so are semicolons, blanks/spaces and many other symbols. The letter a or the digit 1 have no special meaning to the shell and they are not shell metacharacters. Metacharacter (or meta-character) A character that has a special meaning to the shell. These characters are sometimes called “wildcard” characters in other systems. 2 Some definitions Index GLOB patterns or wildcard patterns Characters that the shell will try to expand to match existing pathnames in the file system. The GLOB patterns must always match existing names. GLOB patterns cannot generate any names that do not exist. The shell will try to match the GLOB patterns in those tokens against existing pathnames in the file system to produce a list of existing pathnames. The shell will try to expand any tokens on the command line that contain unquoted GLOB characters into existing pathnames in the file system. Sometimes we say that GLOB patterns match “file names”, but what we really mean is that they match any kind of name. The names being matched by a GLOB pattern can be anything: files, directories, symbolic links, etc. GLOB patterns do not only match file names. Other operating systems may call these wildcard characters. The Unix name for wildcard pattern matching is GLOBbing, from the idea that the pattern matches a “global” list of names. # copy all names starting with 'a' to the parent directory Your shell has a pathname-matching (wildcard) feature that makes operating on large numbers of pathnames easy: $ cp a*. 17 A GLOB pattern that matches only directory names.16 Examples of GLOB use in Bourne shells.15 GLOB patterns do not match or span slashes.14 GLOB patterns apply where they are found.13 GLOB patterns are matched before running the command.12.2 Example of unquoted GLOB using find.12.1 Example of unquoted GLOB using fgrep.12 Unquoted GLOB patterns are hidden problems.11 Unmatched GLOB patterns are passed unchanged.10 GLOB metacharacters never match leading periods (hidden names).9 Pathnames are not GLOBbed a second time.4 Verifying GLOB patterns before using them. 3.3.1 Do not use ranges of letters in lists.3.3 Using to match single characters from a list.3.2 Using ? to match only one single character, any character.3.1 Using * to match any number of any characters. Allen – – Winter 2015 - January to Apil 2015 - Updated 16:44 EDT Shell GLOB patterns (wildcard pathname matching) Shell GLOB patterns (wildcard pathname matching)
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |