use !$ to retrieve filename used with last command

vim !$
the second command 'vim !$' will open test.txt to edit
Sample Output
$ ls test.txt
$ vim !$

0
By: emacs
2010-07-06 01:39:22
vim

These Might Interest You

  • If you have tried to change your prompt and made a mistake, use this command to retrieve a standard prompt. If you used the export command when you changed your prompt, also use it there: export PS1='$PWD$ '


    -2
    PS1='$PWD$ '
    Aldiansblog · 2009-02-13 22:00:57 0
  • w3m is a commanline web browser, full of options, I used -dump_head for less unnecessary page download. With awk, I can retrieve dynamic changes in webpages in this very econnomical fashion Show Sample Output


    -1
    w3m -dump_head www.fiat.com | awk '/Date+/{print $6, $7}'
    m33600 · 2009-06-08 00:06:01 0
  • This command renames the file 'filename' to 'filename.old' using shell expansion. Same as typing "mv filename filename.old".


    -1
    mv filename{,.old}
    BELzEBUB · 2018-03-08 12:41:18 1
  • If you don't escape the - of the filename, you will get the command interpreting it as a parameter, returning (in the best case) an error.


    1
    mv ./-filename filename
    giacomorizzo · 2010-11-17 12:49:28 0

What do you think?

Any thoughts on this command? Does it work on your machine? Can you do the same thing with only 14 characters?

You must be signed in to comment.

What's this?

commandlinefu.com is the place to record those command-line gems that you return to again and again. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.

Share Your Commands



Stay in the loop…

Follow the Tweets.

Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.

» http://twitter.com/commandlinefu
» http://twitter.com/commandlinefu3
» http://twitter.com/commandlinefu10

Subscribe to the feeds.

Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):

Subscribe to the feed for: