2

In bash, I frequently do

touch whatever.py
vim whatever.py

I want something like

touch whatever.py
vim !!

So how do I do that with a bash ! directive that eats the first word?

  • You don't need to use touch since vim will create the file if it doesn't exist (after you :w of course). – styfle Jan 6 '12 at 6:19
  • You're right, bad example. In real life I am actually doing "touchmod", which is a personal alias that touches and then chmods u+x. – AlcubierreDrive Jan 6 '12 at 6:21
4

!* will give you the everything in the previous command except the command itself.

!$ will give you the last parameter for the previous command.

Both should work in your example (a command with a single parameter).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.