Skip to Main Content
Unix in a Nutshell, 4th Edition
book

Unix in a Nutshell, 4th Edition

by Arnold Robbins
October 2005
Intermediate to advanced content levelIntermediate to advanced
908 pages
46h 42m
English
O'Reilly Media, Inc.
Content preview from Unix in a Nutshell, 4th Edition

Special Prompt Strings

Both shells process the value of PS1 for special strings. The Korn shell expands a single ! into the current command number. Use !! to get a literal !. For example:

    PS1='cmd !> '

Bash processes the values of PS1, PS2, and PS4 for the following special escape sequences.

\a

An ASCII BEL character (octal 07).

\A

The current time in 24-hour HH:MM format.

\d

The date in “weekday month day” format.

\D{ format }

The date as specified by the strftime(3) format format. The braces are required.

\e

An ASCII Escape character (octal 033).

\h

The hostname, up to the first period.

\H

The full hostname.

\j

The current number of jobs.

\l

The basename of the shell’s terminal device.

\n

A newline character.

\r

A carriage return character.

\s

The name of the shell (basename of $0).

\t

The current time in 24-hour HH:MM:SS format.

\T

The current time in 12-hour HH:MM:SS format.

\u

The current user’s username.

\v

The version of Bash.

\V

The release (version plus patchlevel) of Bash.

\w

The current directory, with $HOME abbreviated as ~.

\W

The basename of the current directory, with $HOME abbreviated as ~.

\!

The history number of this command.

\#

The command number of this command.

\$

If the effective UID is 0, a #, otherwise a $.

\@

The current time in 12-hour a.m./p.m. format.

\ nnn

The character represented by octal value nnn.

\\

A literal backslash.

\[

Start a sequence of nonprinting ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Learning the Unix Operating System, 5th Edition

Learning the Unix Operating System, 5th Edition

John Strang, Grace Todino, Jerry Peek
UNIX and Linux System Administration Handbook, 5th Edition

UNIX and Linux System Administration Handbook, 5th Edition

Trent R. Hein, Evi Nemeth, Garth Snyder, Ben Whaley, Dan Mackin

Publisher Resources

ISBN: 0596100299Errata Page