4 ms·
Something else really useful: mkdir stuff cd !$ !$ takes the last argument from the previous command, instead of the whole thing. chmod 664 site/* - changes t
by codejoust 16y ago
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
- olalonde 16y ago<ALT>-. does the same thing except it prints it before you hit enter.
- metabrew 16y agoor <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..
- nayanshah 16y ago* is a wildcard for everything in the directory including files and directories. so the chmod will remove the execute permission from directories also.
- pyre 16y ago* will not match hidden files: > ls -a tmp file1 file2 .file3 > ls tmp/* file1 file2 > ls tmp/.* .file3
- BrandonM 16y ago* is a wildcard in general. Its behavior is identical to the .* in a regular expression.
- mrud 16y agoI 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.
- pyre 16y agoYou 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" )