News for hackers. Stuff that matters.
Re:Run last command as root by codejoust on Thursday December 16, 2010 @12:12PM (#2012736)
Something else really useful: mkdir stuff cd !$

!$ takes the last argument from the previous command, instead of the whole thing.

chmod 664 site/* - changes the permissions for all the files in the site directory. * is a wildcard in bash for specifying directories.

Another useful feature of bash is brace expansion: mv site{,-old} => mv site site-old The brace expansion expands the argument with the values in a comma separated list: college pic_00{1,4,3}.jpeg college.jpeg yields pic_001 pic_004, pic_003

Re:Run last command as root by nayanshah on Thursday December 16, 2010 @02:19PM (#2013219)
* is a wildcard for everything in the directory including files and directories. so the chmod will remove the execute permission from directories also.
Re:Run last command as root by pyre on Friday December 17, 2010 @12:14AM (#2015277)
* will not match hidden files:

  > ls -a tmp
    file1
    file2
    .file3
  > ls tmp/*
    file1
    file2
  > ls tmp/.*
    .file3
Re:Run last command as root by olalonde on Thursday December 16, 2010 @12:28PM (#2012811)
<ALT>-. does the same thing except it prints it before you hit enter.
Re:Run last command as root by metabrew on Thursday December 16, 2010 @02:17PM (#2013210)
or <ESC>-. if you recently got a macbook and can't figure out how to remap the silly keyboard defaults and make alt work properly in a terminal..
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"

)
Re:Run last command as root by BrandonM on Thursday December 16, 2010 @02:33PM (#2013270)
* is a wildcard in general. Its behavior is identical to the .* in a regular expression.