Appendix B. If You Use a Different Shell

This book assumes your login shell is bash, but if it’s not, Table B-1 may help you adapt the book’s examples for other shells. The checkmark symbol ✓ indicates compatibility—the given feature is similar enough to bash’s that examples in the book should run correctly. However, the feature’s behavior may differ from bash’s in other ways. Read any footnotes carefully.

Note

Regardless of which shell is your login shell, scripts that begin with #!/bin/bash are processed by bash.

To experiment with another shell installed on your system, simply run it by name (e.g., ksh) and press Ctrl-D when finished. To change your login shell, read man chsh.

Table B-1. bash features supported by other shells, in alphabetical order
bash feature dash fish ksh tcsh zsh

alias builtin

✓, but alias name does not print the alias

No equals sign: alias g grep

Backgrounding with &

bash -c

dash -c

fish -c

ksh -c

tcsh -c

zsh -c

bash command

dash

fish

ksh

tcsh

zsh

bash location in /bin/bash

/bin/dash

/bin/fish

/bin/ksh

/bin/tcsh

/bin/zsh

BASH_SUBSHELL variable

Brace expansion with {}

Use seq

Only {a,b,c}, not {a..c}

Use seq

cd - (toggling directories)

cd builtin

CDPATH variable

set CDPATH value

set cdpath = (dir1 dir2 …​)

Command substitution with $()

Use ()

Use backquotes

Command substitution with backquotes

Use ()

Command-line editing with arrow keys

a

Command-line ...

Get Efficient Linux at the Command Line 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.