Sh-bash-resh-ksh

Source: Internet
Author: User
Tags arithmetic error handling posix
sh,  resh,  ksh,  bash

posix-compliant (korn/bourne-again) shell and command interpreter 

command
 synopsis description options and Invocation options bash Options Command Syntax command Execution word expansion directory Substitution parameter Substitution  Arithmetic Substitution command substitution quoting file descriptors and Redirection File Name Generation variables shell execution environments built-in Commands command line Editing  Emacs/gmacs Editing mode vi Editing mode examples environment variables files diagnostics  portability extensions to posix differences from Unix file Names path Names  Delimiters within Path lists including the current Directory in the path length of Command lines exporting of environment Variables device Error handling limits notes          64-bit note availability see also 
Synopsis

SH [ ±abcefghhikklmnnpprtuvwxx ] [ ±o option] [- D Directory] [- R name, Env_piece, Cmds] [cmd_file [argument ...]

SH [ ±abcefghhikklmnnpprtuvwxx ] [ ±o option] [- D Directory] [- R name, Env_piece, Cmds] - c cmdstring [cmd_name [argument ...]

sh-s [ ±abcefghhikklmnnpprtuvwxx ] [ ±o option] [- D Directory] [- R name, Env_piece, Cmds] [Argument ...]

Resh [ ±abcefghhikklmnnpptuvwxx ] [ ±o option] [- D Directory] [- R name, Env_piece, Cmds] [cmd_file [argument ...]

Resh [ ±abcefghhikklmnnpptuvwxx ] [ ±o option] [- D Directory] [- R name, Env_piece, Cmds] - c cmdstring [cmd_name [argument ...]

resh-s [ ±abcefghhikklmnnpptuvwxx ] [ ±o option] [- D Directory] [- R name, Env_piece, Cmds] [Argument ...]

Ksh [ ±abcefghhiklmnnpprtuvwxx ] [ ±o option] [- D Directory] [- R name, Env_piece, Cmds] [cmd_file [argument ...]

Ksh [ ±abcefghhiklmnnpprtuvwxx ] [ ±o option] [- D Directory] [- R name, Env_piece, Cmds] - c cmdstring [cmd_name [argument ...]

ksh-s [ ±abcefghhiklmnnpprtuvwxx ] [ ±o option] [- R name, Env_piece, Cmds] [- D Directory] [Argument ...]

Bash [Bash_options] [ ±abcefghhikklmnnpprtuvwxx ] [ ±o option] [- R name, Env_piece, Cmds] [- D Directory] [cmd_file [argument ...]

Bash [Bash_options] [ ±abcefghhikklmnnpprtuvwxx ] [ ±o option] [- D Directory] [- R name, Env_piece, Cmds] - c cmdstring [cmd_name [argument ...]

Bash [Bash_options] - S [ ±abcefghhikklmnnpprtuvwxx ] [ ±o option] [- D Directory] [- R name, Env_piece, Cmds] [Argument ...] DESCRIPTION

The sh utility is a sophisticated shell (command interpreter) that offers, depending on the options chosen, Compa Tibility with the Korn, Bourne-again, and POSIX shells available on many UNIX systems. You can use it as a replacement for the standard Windows command interpreter (cmd.exe)

When invoked with the sh name, sh was primarily a posix.2 compatible shell with some selected Korn and Bo Urne-again shell behavior.

Resh is a restricted version of the shell and is equivalent to sh-r . For more information in the restricted shell, see the description of the- r option. Regardless of how it was launched, this reference page uses Resh to refer to the restricted shell.

Ksh  is A version of the shell that uses, by default, standard Korn behavior when it may conflict with  bash  or MKS kornshell behavior.  ksh  is equivalent to running  sh  with the  -K  or  -O   Korn  options. Regardless of how it is launched, this reference page uses  Ksh  to refer to the shell operating In KornShell mode.

Finally, Bash is a version of the shell of this uses, by default, bourne-again shell behavior if it may conflict w ITH MKS KornShell or standard Korn behavior. bash is equivalent to running sh with the- o bash . Regardless of how it's launched, this reference page uses bash to refer to the shell operating in Bourne-again S Hell mode.

This page contains the following subsections:options and invocation command Syntax command execution Word Expansion Direc Tory Substitution Parameter Substitution arithmetic Substitution Command Substitution quoting File descriptors and Redirec tion File Name Generation Variables Shell Execution environments built-in Commands Command line Editing

Subsections dealing with substitution and interpretation of input appear in the order in which the KornShell performs thos e substitutions and interpretations. Options and invocation

The shell can be run interactively or as a script processor. Since Interactive use are most common and it is described first. Normally you invoke the shell by logging in. You can also invoke the shell by typing an explicit sh command (or bash, ksh, or resh) .

On Windows systems, any interactive shell starts by retrieving the set options from the registry. If you invoke the shell with a name of begins with The-character, it's invoked as a login shell which execut Es any profiles files you had set up. (You can also get a login shell if you invoke the shell with- l or --login .) You can use profiles files to customize your session with SH. For example, your profile files can set options, create aliases, or define functions and variables.

A login Shell begins by executing the file:

$ROOTDIR/etc/profile.ksh 	(/etc/profile on UNIX systems)

In bash mode, the shell searches for the following files in order and executes the first one it finds:

$HOME/.bash_profile
$HOME/.bash_login
$HOME/profile.ksh 		($HOME/.profile on UNIX systems)
$HOME/. Profile

Otherwise, in non-bash mode, the shell executes:

$HOME/profile.ksh 		($HOME/.profile on UNIX systems)

Note:

When the shell was searching for a profiles file the home directory and the home environment variable is Not set, the shell instead searches the current directory for a file with the same name and executes it if found.

When you launch a non-login shell in bash mode, the files:

$ROOTDIR/ETC/BASH.BASHRC
$HOME/.BASHRC

is executed in the order listed, if present. If $HOME/.BASHRC does not exist, the shell executes the file specified by the ENV environment variable, if set.

If an interactive shell finds the ENV environment variable set when it begins execution ), it executes the file named by the expansion of the "This variable" (see Variables). However, if the shell is in privileged mode (set by- p or- o privileged ), it instead executes the File

$ROOTDIR/etc/suid_pro.ksh 	($ROOTDIR/etc/suid_profile on UNIX systems)

If you launch a non-interactive, non-privileged shell in bash mode, the file indicated by the bash_env E Nvironment variable is executed instead of the one indicated by ENV.

When ' pedantic POSIX ' mode was set (settable with- o posix or with the posixly_correct and posix_ Pedantic environment variables), the shell does not execute any profile files. It just runs the file indicated by the ENV environment variable, or if in privileged mode, the file:

$ROOTDIR/etc/suid_pro.ksh 	($ROOTDIR/etc/suid_profile on UNIX systems)

Note:

For all profiles files discussed above that has both a window-style and a unix-style name, if the shell does not find a fi Le with the Windows-style name, it searches for a file with the Unix-style name.

If there is at least one argument on the Shell's command line, the first argument is taken as the name of a shell script T o Execute (the exception to this was when- s is used). Any additional arguments is assigned to the positional parameters, which usually serve as arguments to the shell script. See Parameter Substitution for information on positional parameters, and set for information about changing th ESE parameters.

When a login shell in bash mode exits, it executes the following and the files in the order listed if they exist:

$HOME/.bash_logout
$ROOTDIR/bash.bash_logout
Options

- C cmdstring

Executes cmdstring as if it were an input line to the shell and then exits. This is used by programs (for example, editors) that's the shell for a single command. sh assigns arguments in cmdstring to the positional parameters. If you specify Cmd_name, special parameter 0 are set to this string for use when executing the commands in cmdstring.

Note:

sh ignores any command line options follow- c on the command line.

- D Directory

Runs the shell in the specified directory. - G

The

Always writes shell errors to standard error and turns off all GUI features for the running shell. If This option is specified, it overrides  set   -O guierror . -H  

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.