您的位置:首页 > 运维架构 > Shell

bash 历史扩展

2016-05-28 19:03 375 查看
Event Designators

一个事件标志是在历史列表中的命令行条目的参考。除非引用是绝对的,事件是相对于在历史列表中的当前位置。

!

启动历史替换

!n

请参阅命令n行。

!-n

参照当前命令减去ñ。

!!

请参考前面的命令。

!string

请参阅开始用绳子历史记录列表中的当前位置前的最新命令。

!?string[?]

指在包含字符串历史列表中的当前位置之前的最近的命令。尾随?如果字符串是由一个新行紧接着可以省略。

^string1^string2^

快速替换。重复前面的命令,以string2替换字符串string1。.

!#

整个命令行到目前为止输入。

Word Designators

字标志用于选择从该事件所需的词语。它可能如果被忽略 单词标志始于^,$,*, - ,或%。字是从该行的开始编号,与第一个字由0(零)来表示。字插入由单个空格分隔当前行。

0 (zero)

The zeroth word. For the shell, this is the command word.

n The nth word.

^ The first argument. That is, word 1.

$ The last word. This is usually the last argument, but will expand to the zeroth word if there is only one word in the line.

% The word matched by the most recent
?string?' search.

x-y    A range of words;
-y’ abbreviates
0-y'.

*       All of the words but the zeroth.  This is a synonym for
1-′.Itisnotanerrortouse∗ifthereisjustonewordintheevent;theemptystringisreturnedinthatcase.x∗Abbreviatesx−.

x- Abbreviates x-$ like x*, but omits the last word.

如果一个字指示符没有事件规范提供时,先前的命令被用作该事件。

Modifiers

h Remove a trailing filename component, leaving only the head.

t Remove all leading filename components, leaving the tail.

r Remove a trailing suffix of the form .xxx, leaving the basename.

e Remove all but the trailing suffix.

p Print the new command but do not execute it.

q Quote the substituted words, escaping further substitutions.

x Quote the substituted words as with q, but break into words at blanks and newlines.

s/old/new/

Substitute new for the first occurrence of old in the event line. Any delimiter can be used in place of /. The final delimiter is optional if it is

the last character of the event line. The delimiter may be quoted in old and new with a single backslash. If & appears in new, it is replaced by old.

A single backslash will quote the &. If old is null, it is set to the last old substituted, or, if no previous history substitutions took place, the

last string in a !?string[?] search.

& Repeat the previous substitution.

g Cause changes to be applied over the entire event line. This is used in conjunction with
:s' (e.g.,
:gs/old/new/’) or
:&'.  If used with
:s’, any

delimiter can be used in place of /, and the final delimiter is optional if it is the last character of the event line. An a may be used as a synonym

for g.

G Apply the following `s’ modifier once to each word in the event line.
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: