Bash Shell Basic Features II

Source: Internet
Author: User
Tags clear screen

Bash Shell Basic Features II

(1) globbing

Text name wildcard: Meta characters

*: matches any character of any length;

?: matches any single character;

Example: A*b:aab, AB, a123b;

A?b:

[]: matches any single character within the specified range;

Example: [0-9]

[^]: matches any single character outside the range;

Example: [^a-b]


Character Set:

[: Lower:] matches lowercase letters. Equivalent to A-Z

[: Upper:] matches uppercase letters. Equivalent to A-Z

[: Alnum:] matches letters and numbers. Equivalent to a-za-z0-9

[:d Igit:] Matches (decimal) number. Equivalent to 0-9

[: Space:] matches white space characters (whitespace and horizontal tabs)

[:p UNCT:] Match symbol

[: Alnum:] matches letters and numbers. Equivalent to a-za-z0-9


Example:

Display/etc/directory, beginning with a non-letter, followed by a letter and any other arbitrary length of any character file or directory;

ls/etc/[^a-z][a-z]*


Copy all files or directories ending with. D in the/etc directory to the/tmp/mageedu.com directory;

Cp-r/etc/*.d/tmp/mageedu.com


(2) shortcut keys, combination keys


Ctrl+l: Clear Screen

CTRL + A: switch to the beginning of the command

Ctrl+e: Switch to the end of the command line

CTRL + C: Cancel command execution

Ctrl+u: Deletes the contents of the cursor at the beginning of the line;

Ctrl+k: Delete the contents of the cursor at the end of the line;



(3) IO input/output redirection and piping


Program: Instruction + data

Read-in data: Input

Outputs data: Output


The open files are all a Fd:file descriptor


Standard input: Keyboard, 0,/dev/stdin

Standard output: Monitor, 1,/dev/stdout

Standard error Output: monitor, 2,/dev/stderr

Output redirection:, >>//format: command > New_pos, command >> New_po

: The original content in the target file will be erased;

>>: New content is appended to the end of the target file;


# set-c: Prohibit use of overwrite output redirection

You can still use >| to force overwrite

# set +c


Error output redirect: 2>, 2>>

2>: Overwrite

2>>: Append

Redirect both the standard output stream and the error output stream at the same time:

Example:

COMMAND >/path/to/file.out 2>/path/to/file.err


Merge the data flow of standard output and error output to the same place: &>, &>>

&>

&>>

Example:

COMMAND >/path/to/file.out 2>&1

COMMAND &>/path/to/file.out


Enter redirection:

<


TR command: Convert or delete characters

Syntax format: TR [OPTION] ... SET1 [SET2]

Common parameters:

-D: Delete characters

Here document:<<

# Cat << EOF

# cat > file name << EOF



(4) Pipeline: Connect command, implement the output of the previous command as input to the latter command

COMMAND1 | COMMAND2 | ...

Example:

Converts the first two messages logged to all users on the current system to uppercase output;

# who | head-2 | Tr ' A-Z ' A-Z


This article is from the "10,000-hour Law" blog, be sure to keep this source http://daisywei.blog.51cto.com/7837970/1687817

Bash Shell Basic Features II

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.