Differences between revisions 21 and 22
Revision 21 as of 2025-12-19 20:07:48
Size: 4053
Comment: Reorg
Revision 22 as of 2025-12-19 20:08:38
Size: 4378
Comment: Pruning dead links
Deletions are marked like this. Additions are marked like this.
Line 23: Line 23:
||`dirs` || || ||
||`disown` || || ||
||`echo` || || ||
||`enable` || || ||
||`dirs` ||                 || ||
||`disown` ||                 || ||
||`echo` ||                 || ||
||`enable` ||                 || ||
Line 31: Line 31:
||`fc` || || ||
||`getopts` || || ||
||`hash` || || ||
||`fc` ||                 || ||
||`getopts` ||                 || ||
||`hash` ||                 || ||
Line 35: Line 35:
||`history` || || ||
||`kill` || || ||
||`let` || || ||
||`history` ||                 || ||
||`kill` ||                 || ||
||`let` ||                 || ||
Line 40: Line 40:
||`mapfile` || || ||
||`popd` || || ||
||`printf` || || ||
||`pushd` || || ||
||`mapfile` ||                 || ||
||`popd` ||                 || ||
||`printf` ||                 || ||
||`pushd` ||                 || ||
Line 45: Line 45:
||`read` || || ||
||`readarray` || || ||
||`readonly` || || ||
||`read` ||                 || ||
||`readarray` ||                 || ||
||`readonly` ||                 || ||
Line 51: Line 51:
||`source` || || || ||`source` ||                 || ||
Line 53: Line 53:
||`time` || || ||
||`trap` ||Creates a [[Bash/Trap|here]]|| ||
||`typeset` || || ||
||`time` ||                 || ||
||`trap` ||Creates a trap   || ||
||`typeset` ||                 || ||
Line 58: Line 58:
||`wait` || || || ||`wait` ||                 || ||

Bash Builtin Commands

The set of portable commands.


Commands

Command

Description

Example

.

Alias for source

:

No-op

alias

Creates an alias

bind

builtin

Executes a builtin command

caller

cd

Changes the current working directory

command

Executes a command

declare

Set a variable, optionally with a value

dirs

disown

echo

enable

eval

Executes a command

exec

Replaces the shell with a command

exit

Causes a script or shell to exit immediately

export

Marks one or more names as variables to be included in the environment of subsequently-called commands

export varname="some value"

fc

getopts

hash

help

Prints helpful information about a builtin command

history

kill

let

local

Only valid within a function definition; see here

logout

Exits a login shell immediately

mapfile

popd

printf

pushd

pwd

Prints the current working directory

read

readarray

readonly

set

Sets a shell option

shift

Renames the positional variables

shopt

Sets a shell option

source

test

Executes a test

time

trap

Creates a trap

typeset

unalias

Removes an alias

unset

Unsets a shell option

wait

Builtin

builtin can be useful to call a builtin command when there is a custom command with the same name.

Cd

Calling cd without an argument is the same as cd ~.

cd - changes the current working directory to the previous working directory.

Command

command can be useful to call a command when there is a function with the same name.

command is also commonly used to determine if a command is locally available.

if ! command -v mypy >/dev/null 2>&1; then
  echo "cannot locate mypy; is it installed?"
  exit
fi

Declare

When used within a function definition, the variable is set to local scope.

To create a variable that is marked for export, use:

declare -x myvar

To create a variable that is marked for tracing, use:

declare -t myvar

To create a read-only constant, use:

declare -r myconst

To create an integer variable, use:

declare -i myinteger

To create an array, use:

declare -a myarray

To create an associative array, use:

declare -A myarray

With some exceptions, these options can be combined. Additionally, options can be explicitly disabled by substituting the dash (-) with a plus sign (+).


Reserved Keywords

Some parts of the language are technically implemented as a command.

See here for break and continue.

See here for return.

See here for compgen, complete, and compopt`.

See here for bg, coproc, fg, and jobs.


CategoryRicottone

Bash/BuiltinCommands (last edited 2025-12-19 20:18:05 by DominicRicottone)