Linux study notes _ 3_common Linux commands _ 8_Shell usage tips

Source: Internet
Author: User
Shell application tips: Tips: 1. command complementing function: & lt; Tab & gt; Key 2. clear screen: Ctrl & amp; 43; l & amp; 20284 ;: clear [DOS: cls] 3. delete all content before the cursor: Ctrl & amp; 43; u4. Command history: history ,! Commands listed by history

Shell application tips:

Tips:

1. command complementing: Key

2. clear screen: Ctrl + l

Similar to: clear [DOS: cls]

3. delete all content before the cursor: Ctrl + u

4. Command history: history

Now ,! The command number listed by history to execute the command. // Not commonly used

Example :! 188

At the same time, you can find commands that have been previously executed by pressing the arrow keys "Dig" and "dig.

Important skills:

1. command alias:

Purpose: make operations easier, and make commands easier to remember.

Alias: displays the alias defined by the system.

Define alias:

Aliascopy = cp

Aliasdrm = "rm-rf" // defines the alias combination, which must be caused ""

Delete alias:

Unalia scopy

Appendix: in most cases, the UNIX system does not set these aliases!

2. input/output redirection:

0 (STDIN) standard input, keyboard;

1 (STDOUT) standard output, display;

2 (STDERR) standard error output, display.

> Or> output redirection

Ls-l/tmp> test.txt // clear the original file content

Ls-l/tmp> test.txt // Append

<输入重定向< p>

Wall <test.txt // input redirection

2> error output redirection

Cp-R/usr/backup/usr. bak 2>/bak. error

3. pipelines

Send the output of one command to another as the input of another command.

Ls-l/etc | more

Ls-l/etc | grep init

Ls-l/etc | grep init | wc-l // The wc command is a counter.

4. command connector

1 );

Run the commands at intervals in sequence.

Pwd; ls; date

2 )&&

Command1 & command2

Executed successfully

Failed to execute

There is a logic and relationship between the execution of the front and back commands. only after & the preceding command is successfully executed will the subsequent commands be executed.

3) |

Command1 | command2

Execute not run

Do not execute

There is a logic or relationship between the execution of the preceding and following commands. only after the execution of the preceding command fails can the execution of the following commands be executed.

For details, refer to my other series of blogs:

Four days proficient in Shell programming series:

Http://blog.csdn.net/zjf280441589/article/details/17455515

Http://blog.csdn.net/zjf280441589/article/details/17467069

Http://blog.csdn.net/zjf280441589/article/details/17487351

Http://blog.csdn.net/zjf280441589/article/details/17503985

5. replace float with commands

Command 1 'command 2'

Use the output of Command 2 as the parameter of Command 1 to simplify the operation.

E.g. ls-l 'which touch'

Appendix:

Cat/etc/shells

Lists all shells supported by the current system.

In Linux, bash/bin/bash is used by default.

Older UNIX bin/sh

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.