$_ today’s favorite bash shortcut of the day

In Bash and several other shells $_ stores the arguments of the most recent command.  This lets you do something like:

mkdir fun
cd $_

That’s a simple example, making a directory and switching into it.  Where it really comes in handy is when you’re like me and you give the wrong command with a million arguments and want to quickly fix your mistake.  $_ to the rescue!

Advertisements
  1. Thanks for this tips it’s usefull like this one
    !!
    or
    sudo !!
    and this :
    !m #repeat your last command beginning with m like mkdir fun ^_^
    I’ve got another one

    • I wish I knew how many times a day I used sudo !!. I wish I knew why I think I can run pacman with normal user privileges.

  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: