/usr/bin/bash: Difference between revisions

 
(One intermediate revision by the same user not shown)
Line 1,868: Line 1,868:


=== Word Designators ===
=== Word Designators ===
Word designators are used to select desired words from the event.  A : separates the event specification from the word designator.  It may be omitted if the word designator begins with a ^$, *, -, or %.  Words are numbered from the beginning of the line, with the first word being denoted by 0 (zero).  Words are inserted into the current line separated by single spaces.
単語指定子は、イベントから必要な単語を選択するために使用される。 は、イベントの指定と単語指示子を区切る。 単語指定子が^$*-%で始まる場合は省略できる。 単語は行頭から順に番号付けされ、最初の単語は0(ゼロ)で示される。 単語は、現在の行に半角スペースで区切って挿入される。


;0 (zero)
;0 (zero)
:The zeroth word.  For the shell, this is the command word.
:番目の単語。 シェルでは、これはコマンドワードである。
;n
;n
:The nth word.
:The nth word.
;^
;^
:The first argument.  That is, word 1.
:最初の引数。 つまり単語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.
:最後の単語。 これは通常最後の引数だが、行に単語が1つしかない場合は0番目の単語に展開される。
;%
;%
:The  first  word matched by the most recent `?string?' search, if the search string begins with a character that is part of a word.
:検索文字列が単語の一部である文字で始まっている場合、直近の `?string?' 検索でマッチした最初の単語。
;x-y
;x-y
:A range of words; `-y' abbreviates `0-y'.
:'-y'は'0-y'を省略したものである。
;*
;*
:All of the words but the zeroth.  This is a synonym for `1-$'.  It is not an error to  use * if there is just one word in the event; the empty string is returned in that case.
:0番目以外のすべての単語。 これは `1-$' と同意語である。 その場合は空文字列が返される。
;x*
;x*
:Abbreviates x-$.
:Abbreviates x-$.
;x-
;x-
:Abbreviates x-$ like x*, but omits the last word.  If x is missing, it defaults to 0.
:x*のようにx-$を省略するが、最後の単語は省略する。 xがない場合、デフォルトは0になる。


If  a word designator is supplied without an event specification, the previous command is used as the event.
イベント指定なしで単語指定子を与えた場合、前のコマンドがイベントとして使用される。


=== Modifiers ===
=== Modifiers ===
After the optional word designator, there may appear a sequence of one or more of  the  following modifiers,  each  preceded  by a `:'.  These modify, or edit, the word or words selected from the history event.
オプションの単語指示子の後には、それぞれ`:'で始まる1つ以上の修飾子が現れる。 これらは、履歴イベントから選択された単語を修正する。


;h
;h
:Remove a trailing filename component, leaving only the head.
:末尾のファイル名コンポーネントを削除し、先頭だけを残す。
;t
;t
:Remove all leading filename components, leaving the tail.
:ファイル名の先頭をすべて削除し、末尾を残す。
;r
;r
:Remove a trailing suffix of the form .xxx, leaving the basename.
:.xxx 形式の末尾のサフィックスを削除し、ベース名を残す。
;e
;e
:Remove all but the trailing suffix.
:末尾の接尾辞以外はすべて削除する。
;p
;p
:Print the new command but do not execute it.
:新しいコマンドを表示するが、実行はしない。
;q
;q
:Quote the substituted words, escaping further substitutions.
:置換された単語を引用し、それ以上の置換を避ける。
;x
;x
:Quote the substituted words as with q, but break into words at blanks and newlines.  The q and x modifiers are mutually exclusive; the last one supplied is used.
:qと同様に置換された単語を引用するが、空白と改行で単語を区切る。 q修飾子とx修飾子は互いに排他的であり、最後に与えられたものが使われる。
;s/old/new/
;s/old/new/
:Substitute  new  for  the first occurrence of old in the event line.  Any character may be used as the delimiter 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.  If  new  is  null,  each matching old is deleted.
:イベント行で最初に出現するoldをnewに置き換える。 最後のデリミタは、イベント行の最後の文字であれば任意である。 デリミタは、バックスラッシュ1つでoldとnewで引用することができる。 もし&がnewに現れた場合、それはoldに置き換えられる。 シングル・バックスラッシュは&を引用符で囲む。 oldがNULLの場合、最後に置換されたoldに設定され、それ以前に履歴の置換が行われなかった場合は、!?string[?]検索の最後の文字列に設定される。 newがNULLの場合、一致するoldはすべて削除される。
;&
;&
:Repeat the previous substitution.
:前の置換を繰り返す。
;g
;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.
:変更をイベント行全体に適用する。 これは `:s' (例えば `:gs/old/new/') または `:&' と組み合わせて使う。 s' と一緒に使う場合、/の代わりにどんな区切り文字でも使うことができ、最後の区切り文字がイベント行の最後の文字であれば省略可能である。 gの同義語としてaを使うこともできる。
;G
;G
:Apply the following `s' or `&' modifier once to each word in the event line.
:以下の`s'または`&'修飾子をイベント行の各単語に1回ずつ適用する。


== SHELL BUILTIN COMMANDS ==
== SHELL BUILTIN COMMANDS ==