One of the basic features of the bash shell

Source: Internet
Author: User
Tags aliases

One of the basic features of the bash shell

First, the Order history

Bash records the command that the user executed in the shell session in the buffer, and when it exits normally, it is recorded in the current user's home directory. Bash_history;

Environment variables:

Histsize: The number of records in the command history;

Histfile: Command history file path;

Histfilesize:

History command:

-C: Clears the command history;

-D #: Deletes the command specified in the history;

-A: When the history in the buffer is manually appended files;

History #: Shows the number of recent commands;

Invoke commands that have been executed in the past:

!#: Call the # # command in history;

!: Repeat the previous command

!string: Invokes the last command in history that starts with a string;

Call the last parameter of a command that has been executed in the past:

!$:

Esc.

ALT +.


Second, command completion

Command Search mechanism:

Path environment variables: paths separated by colons

Hash: The previous search to the path cache into memory;

Kv:key-value

LS--/bin/ls

Command completion: TAB


Third, Path completion

Starts the current path of the path string given by the user and searches for the file name at the beginning of the specified string, under its specified parent directory;

If only: direct completion;

Otherwise: two times tab, can be listed;


Four, command line expansion of the function

~: Expands to the current user's home directory;

~username: Expands the home directory for the specified user;

{}: Can host a comma-delimited list and expand it to multiple paths;

/var/{log,cache,run} =/var/log/var/cache/var/run


V. Execution result status of the command, tracked and saved by bash

Success: 0

Failed: 1-255

Bash uses a special variable $? To save the status result of the most recent command;

There are two ways to execute a program:

The return value of the program;

The status result of the program;


Six, command aliases

Another reference symbol for the command, maintained by the Bash program;

Alias/unalias

Alias: view all defined aliases;

Alias Name=command: Define aliases;

If the alias is the same as the original command name and you want to execute the original command directly, you need to use \command

Unalias name: Revoke alias;


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

One of the basic features of the bash shell

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.