Reputation: 1245
I was curious if there is a way to index the current line in bash as it might save quite a bit of typing.
e.g.
$ command longarg1 longarg2 longarg3 | command2 <something_to_expand_longarg2>
I tried !#2 (!# will give expand the contents of the line so far) However it did not work as it will expand the whole line and then put 2.
-Thanks
Upvotes: 3
Views: 112
Reputation: 798616
From the bash(1)
man page, HISTORY EXPANSION section, Word Designators subsection:
A : separates the event specification from the word designator.
$ command longarg1 longarg2 longarg3 | command2 !#:2
Upvotes: 4
Reputation: 47267
Not indexing as you have asked, and not ideal exactly, but how about:
(environment dependent)
Upvotes: 0