Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

History completely removes the historical life.

2025-01-14 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

1. Clear the history command

2. Clear the cache

3. Exit command

Command line history

Repeat the previous command, there are four ways

Repeat the previous command using the up key and press enter to execute

Press! And enter to execute.

Enter!-1 and enter to execute.

Press Ctrl+p and press enter to execute

!: 0 execute the previous command (remove parameters)

Ctrl + n displays the next command in the current history, but does not execute

Ctrl + j executes the current command

! n execute the history command to output the command corresponding to the serial number n

!-n executes the last but one command in history history

Command line history

! string repeats the previous command that starts with "string"

!? string repeats the previous command containing string

! string:p only prints command history, not executes it

! $: P printout! $(the last parameter of the previous command)

! *: P printout! * (all parameters of the previous command)

^ string deletes the first string in the previous command

^ string1 ^ string2 replaces the first string1 in the previous command with string2

!: gs/string1/string2 replaces all string1 in the previous command with string2

Command line history

Use the up (up) and down (down) keys to browse up and down the previously entered command

Ctrl-r to search for commands in the command history

(reverse-i-search) `':

Ctrl+g: exit from historical search mode

To recall the last argument in the previous command

! $means

Esc,. (click the ESC key and release, then click. Key)

Alt+. (hold down the Alt key and click. Key)

Call history parameter

Command! ^ use the first parameter of the previous command to do the parameter of cmd

Command! $use the last parameter of the previous command to do the parameter of cmd

Command! * use all the parameters of the previous command to do the parameters of cmd

Command!: n use the nth argument of the previous command to do the parameter of cmd

Command! n: ^ invokes the first argument of the article n command

Command! NVR $invokes the last argument of the article n command

Command! NVR m invokes the m argument of the nth command

Command! NRV * invokes all the parameters of the article n command

thirty

Command! string: ^ search the command history for a command that begins with string and get its first

Parameters

Command! string:$ searches the command history for a command that begins with string and gets its last

Parameters

Command! string:n searches the command history for a command that begins with string and gets its nth

Parameters

Command! string:* searches the command history for commands that begin with string and gets all of its

Parameters.

Call history parameter

Command history

History [- c] [- d offset] [n]

History-anrw [filename]

History-ps arg [arg...]

-c: clear command history

-d offset: delete the offset command specified in history

N: show the most recent n histories

-a: append the history list of newly executed commands in this session to the history file

-r: read the history file and attach it to the history list

-w: save the history list to the specified history file

-n: read the unread lines in the history file to the history list

-p: expand the history parameter into multiple lines, but it does not exist in the history list

-s: expand the history parameter into a line and append it to the history list

Command history-related environment variables

HISTSIZE: number of command history entries

HISTFILE: specify a history file. Default is ~ / .bash_history

HISTFILESIZE: the number of entries recorded in the command history file

HISTTIMEFORMAT= "F% T" display time

HISTTIMEFORMAT formats the history command time

Echo 'HISTTIMEFORMAT= "F% T `whoami`" > > / etc/bashrc

When the whoami is finished, there must be a space after it, or it will be connected with the command.

= =

Add a line under / etc/bashrc:

HISTTIMEFORMAT= "F% T `whoami`"

HISTIGNORE= "str1:str2*:..." ignores the str1 command, the history at the beginning of str2

Controls how command history is recorded:

Environment variable: HISTCONTROL

Ignoredups defaults to ignore duplicate commands, and "repeat" is consecutive and identical.

Ignorespace ignores all commands that start with white space

Ignoreboth is equivalent to the combination of ignoredups and ignorespace

Erasedups removes duplicate commands

Export variable name = "value"

Stored in / etc/profile or ~ / .bash_profile

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report