export PATH="/usr/local/bin:$PATH"
export EDITOR=vim
export -p # List all exported variables
unset
Remove variables
unset name # Remove variable
unset -f function_name # Remove function
Special variables
Predefined shell variables
$HOME # Home directory
$PATH # Executable search path
$? # Exit status of last command
$$ # Current process ID
$# # Number of arguments
$0 # Script name
Variable expansion
Advanced variable manipulation
${var:-default} # Use default if unset
${var#prefix} # Remove prefix
${var%suffix} # Remove suffix
${var//old/new} # Replace all occurrences
while getopts ":a:b:" opt; do
case $opt in
a) arg_a=$OPTARG;;
b) arg_b=$OPTARG;;
\?) echo "Invalid option: -$OPTARG";;
esac
done
7
Keyboard Shortcuts
Editing shortcuts
Command line editing
Ctrl+A # Move to beginning of line
Ctrl+E # Move to end of line
Ctrl+K # Delete to end of line
Ctrl+U # Delete to beginning of line
Ctrl+W # Delete previous word
Completion
File and command completion
Esc, Esc # Complete filename
Ctrl+D # List possible completions
Tab # Complete command (if set)
History navigation
Browse command history
Up/Down # Navigate history
Ctrl+P # Previous command
Ctrl+N # Next command
Ctrl+R # Reverse search
Process control
Manage running processes
Ctrl+C # Interrupt process
Ctrl+Z # Suspend process
Ctrl+D # End of input (logout)
Ctrl+S # Pause output
Ctrl+Q # Resume output