News for hackers. Stuff that matters.
Re:Damn Useful: When You Forget to type Sudo by yan on Tuesday December 09, 2008 @11:38AM (#391418)
You can also get at the arguments of the previous command line with !!:n, where n is the position of the argument.

i.e.

  host:test user$ touch one two three four five
  host:test user$ ls
  five	four	one	three	two
  host:test user$ cat four
  host:test user$ echo !!:1
  echo four
  four
Also, "Esc, dot" is an awesome bash shortcut. (Press them consecutively, not concurrently). It inserts the last argument of the previous command in place. So if you're doing something to the same file, Esc, . will usually bring up the file name.

i.e.

  host:test user$ cat five
  host:test user$ touch [Esc, .]
Re:Damn Useful: When You Forget to type Sudo by lanaer on Tuesday December 09, 2008 @12:11PM (#391452)
Easier than [Esc, .] is !$. Does the same thing.
Re:Damn Useful: When You Forget to type Sudo by yan on Tuesday December 09, 2008 @12:16PM (#391460)
Either work, it all amounts to habit. My fingers are just used to hitting esc, . and it's nice to see the argument get inserted inline as I'm editing.
Re:Damn Useful: When You Forget to type Sudo by matstc on Tuesday December 09, 2008 @02:57PM (#391679)
Except you can press [esc, .] multiple times.
Re:Damn Useful: When You Forget to type Sudo by callahad on Tuesday December 09, 2008 @01:22PM (#391536)
In most "Esc then X" cases, you should also be able to type Alt+X, which jives better with some folks' preferences.