4

I know I can reuse the first argument from the prævious command with !:1; but is it possible to reuse an already typed argument from the command currently being entered? Say I want to cp blablabla blablabla.bak (and assume there are other similarly named files in the directory); it would be nice not to have to type blablabla all over again.

1 Answer 1

8

Yes; you can use the history expansion !# to represent the current line so far:

cp blablabla !#:1.bak
Sign up to request clarification or add additional context in comments.

1 Comment

+1; I had no idea. For the OP's specific case, by the way, another option is brace expansion: cp blablabla{,.bak}.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.