* is a wildcard for everything in the directory including files and directories.
so the chmod will remove the execute permission from directories also.
* will not match hidden files:
> ls -a tmp
file1
file2
.file3
> ls tmp/*
file1
file2
> ls tmp/.*
.file3<ALT>-. does the same thing except it prints it before you hit enter.
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..
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.
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"
)
!$ 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