Syntax

This subsection describes the many symbols peculiar to bash. The topics are arranged as follows:

  • Special files

  • Filename metacharacters

  • Command-line editing

  • Quoting

  • Command forms

  • Redirection forms

  • Coprocesses

Special Files

File

Purpose

/etc/profile

Executed automatically at login.

$HOME/.bash_profile

Executed automatically at login.

$HOME/.bashrc

Executed automatically at shell startup.

$HOME/.bash_logout

Executed automatically at logout.

$HOME/.bash_history

Record of last session’s commands.

$HOME/.inputrc

Initialization file for reading input in an interactive shell.

/etc/passwd

Source of home directories for ~ name abbreviations.

Filename Metacharacters

Characters

Meaning

*

Match any string of zero or more characters.

?

Match any single character.

[ abc ...]

Match any one of the enclosed characters; a hyphen can be used to specify a range (e.g., a-z, A-Z, 0-9).

[! abc ...]

Match any character not among the enclosed characters.

[^ abc ...]

Same as [! abc ...].

{ str1 ,...}

Brace expansion: match any of the enclosed strings.

~ name

HOME directory of user name. With no name, HOME directory of current user.

~+

Current working directory (PWD).

~-

Previous working directory from directory stack (OLDPWD; see also the pushd built-in command).

~+ n

The nth entry in the directory stack, counting from the start of the list with the first entry being 0.

~- n

The nth entry in the directory stack, counting ...

Get Linux in a Nutshell, Fourth Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.