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
/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.

{ str1 ,...}

Brace expansion: match any of the enclosed strings.

~ name

HOME directory of user name.

~+

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 from the end of the list with the last entry being 0.

Patterns can be a sequence of patterns separated by |; if any of the subpatterns match, the entire sequence is considered matching. This extended syntax resembles that available ...

Get Linux in a Nutshell, Third 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.