• Home
  • Search Tags
  • About

sh

Topics related to sh:

Getting started with sh

sh is not a single shell. Rather, it is a specification with the POSIX operating system standard for how a shell should work. A script that targets this specification can be executed by any POSIX-compliant shell, such as

  • bash
  • ksh
  • ash and its derivatives, such as dash
  • zsh

In a POSIX-compliant operating system, the path /bin/sh refers to a POSIX-compliant shell. This is usually a shell that has features not found in the POSIX standard, but when run as sh, will restrict itself to the POSIX-compliant subset of its features.

References

  • Standard sh
  • The FreeBSD sh(1) man-page
  • The NetBSD sh(1) man-page
  • The OpenBSD sh(1) man-page
  • The Illumos sh(1) man-page (ksh93(1))

The `read` command

Quoting

References

  • The POSIX 'Shell Command Language' section on 'Quoting'

Arithmetic Expansion

Numbers in arithmetic expansions must match the following ERE:

[-+]?(0[0-7]+|[1-9][0-9]*|0[Xx][0-9A-Fa-f]+)

Arithmetic expressions support signed integer operators, comparisons, Boolean expressions, assignments, and ternary expressions from C.

Resources

  • Arithmetic expansion in POSIX
  • Operator precedence

Job Control

Test

If test(1) is run without any arguments it returns false.

Reference

  • Standard test(1)
  • The FreeBSD test(1) man-page
  • The NetBSD test(1) man-page
  • The OpenBSD test(1) man-page
  • The Illumos test(1) man-page
  • The GNU Coreutils online manual section on test(1)

IO Redirection

Resources

  • The POSIX 'Shell Command Language' section on 'Redirection'

Content on the page is taken from Stack Overflow Documentation

This site is NOT affiliated with Stack Overflow or any of the contributors. | Privacy Policy | Terms of Service