Skip to content


Cool Shell Tricks

shopt -s cdspell "minor errors in the spelling of a directory
component in a cd command will be corrected"

pushd/popd/dirs

"Directory stacks"

binary <<< here docs

"single line here docs"
!foo "repeat last command that started with foo"
^find^replace^ "repeat last command, but replace find with
replace"
${!tmp_var} "Indirect reference to the contents of the
variable whose name is in tmp_var"

shopt -s nullglob

"Expand failed globs to null"
something with IFS "IFS is the input field separator"
OPTION=${OPTION:-"default"} "Default values in variable expansions."
[[ expr ]] "Double-bracket: Do what I mean!"
(if in zsh)

cd build/arch1/foo

cd arch1 arch2
"will search and replace on current directory
then switch to new directory"

Posted in Articles.