/usr/bin/bash: Difference between revisions

Line 2,369: Line 2,369:


=== Modifiers ===
=== Modifiers ===
      After the optional word designator, there may appear a sequence of one or more of  the  following
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.
      modifiers,  each  preceded  by a `:'.  These modify, or edit, the word or words selected from the
      history event.


      h     Remove a trailing filename component, leaving only the head.
;h
      t     Remove all leading filename components, leaving the tail.
:Remove a trailing filename component, leaving only the head.
      r     Remove a trailing suffix of the form .xxx, leaving the basename.
;t
      e     Remove all but the trailing suffix.
:Remove all leading filename components, leaving the tail.
      p     Print the new command but do not execute it.
;r
      q     Quote the substituted words, escaping further substitutions.
:Remove a trailing suffix of the form .xxx, leaving the basename.
      x     Quote the substituted words as with q, but break into words at blanks and newlines.  The q
;e
              and x modifiers are mutually exclusive; the last one supplied is used.
:Remove all but the trailing suffix.
      s/old/new/
;p
              Substitute  new  for  the first occurrence of old in the event line.  Any character may be
:Print the new command but do not execute it.
              used as the delimiter in place of /.  The final delimiter is optional if it  is  the  last
;q
              character  of  the  event  line.  The delimiter may be quoted in old and new with a single
:Quote the substituted words, escaping further substitutions.
              backslash.  If & appears in new, it is replaced by old.  A single backslash will quote the
;x
              &.  If old is null, it is set to the last old substituted, or, if no previous history sub‐
: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.
              stitutions took place, the last string in a !?string[?]  search.  If  new  is  null,  each
;s/old/new/
              matching old is deleted.
: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.
      &     Repeat the previous substitution.
;&
      g     Cause  changes to be applied over the entire event line.  This is used in conjunction with
:Repeat the previous substitution.
              `:s' (e.g., `:gs/old/new/') or `:&'.  If used with `:s', any  delimiter  can  be  used  in
;g
              place  of  /, and the final delimiter is optional if it is the last character of the event
: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.
              line.  An a may be used as a synonym for g.
;G
      G     Apply the following `s' or `&' modifier once to each word in the event line.
:Apply the following `s' or `&' modifier once to each word in the event line.


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