News for hackers. Stuff that matters.
Re:Run last command as root by mrud on Thursday December 16, 2010 @04:45PM (#2013868)
I have a function for it which is quite useful: mcd () { mkdir "$@" cd "$@" }

Just run mcd foobar and you (try) to create the directory and enter it. IMO a nice shortcut.

Re:Run last command as root by pyre on Friday December 17, 2010 @12:09AM (#2015267)
You know that mkdir can take multiple directories? If you run:

  mcd dir1 dir2 dir3
That function will run:

  mkdir "dir1" "dir2" "dir3" cd "dir1" "dir2" "dir3"
(Surrounding $@ with double quotes, puts quotes around each item instead of quotes around the whole string:

  command "directory1/sub directory" "directory2"

    $@ => directory1/sub directory directory2
  "$@" => "directory1/sub directory" "directory2"
  "$*" => "directory1/sub directory directory2"

)