Shell Programming (i)

Source: Internet
Author: User

One of the basic features of bash:


Command history: The shell process saves commands that were previously executed by the user in its session;

~]# history

The ability to customize the history can be achieved through environment variables:

The number of commands history that the Histsize:shell process can retain;

Histfile: A file that persists command history;

. bash_history

Histfilesize: The size of the command history file;


Command usage:

History [-c] [-D offset] [n]

or HISTORY-ANRW [filename]

or history-ps parameter [parameters ...]


-C: Clears the command history;

-D Offset: Delete the specified command history

-R: Reads the command history from the file to the history list;

-W: Appends the commands in the history list to the history file;

History #: Displays the most recent # command;


To invoke a command in the command history list:

!#: Once again execute the # command in the history list;

!! : To execute the last command once more;

! String: Executes the most recent command in the command history list that starts with a string;


Note: Repeated executions of commands sometimes need to depend on idempotent;


Call the last parameter of the previous command:

Shortcut key: ESC,.

String:!$


Control the way the command history is logged:

Environment variable: Histcontrol

Ignoredups: Ignore duplicate commands;

Ignorespace: Ignores commands that begin with whitespace characters;

Ignoreboth: Both are effective at the same time;


To modify the value of a variable:

Name= ' VALUE '


Shell Programming (i)

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.