dash 命令详解

| 选择喜欢的代码风格  

A B C D E F G H I J K L M N O P Q R S T U V W X Y Z

dash 命令安装:


-bash/zsh: dash command not found

#Debian
apt-get install dash

#Ubuntu
apt-get install dash

#Alpine
apk add dash

#Arch Linux
pacman -S dash

#Kali Linux
apt-get install dash

#CentOS
yum install dash

#Fedora
dnf install dash

#OS X
brew install dash

#Raspbian
apt-get install dash

#Docker
docker run cmd.cat/dash dash

dash 命令补充说明:


DASH 是 /bin/sh 的符合 POSIX 的实现,旨在尽可能小。 它在不牺牲速度的情况下尽可能做到这一点。 事实上,对于大多数任务,它比 bash(GNU Bourne-Again SHell)快得多

dash 命令语法:


dash [-aCefnuvxIimqVEb] [+aCefnuvxIimqVEb] [-o option_name]
    [+o option_name] [command_file [argument ...]]

dash -c [-aCefnuvxIimqVEb] [+aCefnuvxIimqVEb] [-o option_name]
    [+o option_name] command_string [command_name [argument ...]]

dash -s [-aCefnuvxIimqVEb] [+aCefnuvxIimqVEb] [-o option_name]
    [+o option_name] [argument ...]

dash 命令选项:


-a allexport     Export all variables assigned to.

-c               Read commands from the command_string
                operand instead of from the standard input.
                Special parameter 0 will be set from the
                command_name operand and the positional
                parameters ($1, $2, etc.)  set from the
                remaining argument operands.

-C noclobber     Don't overwrite existing files with “>”.

-e errexit       If not interactive, exit immediately if any
                untested command fails.  The exit status of
                a command is considered to be explicitly
                tested if the command is used to control an
                if, elif, while, or until; or if the command
                is the left hand operand of an “&&” or “||”
                operator.

-f noglob        Disable pathname expansion.

-n noexec        If not interactive, read commands but do not
                execute them.  This is useful for checking
                the syntax of shell scripts.

-u nounset       Write a message to standard error when
                attempting to expand a variable that is not
                set, and if the shell is not interactive,
                exit immediately.

-v verbose       The shell writes its input to standard error
                as it is read.  Useful for debugging.

-x xtrace        Write each command to standard error
                (preceded by a ‘+ ’) before it is executed.
                Useful for debugging.

-I ignoreeof     Ignore EOF's from input when interactive.

-i interactive   Force the shell to behave interactively.

-l               Make dash act as if it had been invoked as a
                login shell.

-m monitor       Turn on job control (set automatically when
                interactive).

-s stdin         Read commands from standard input (set
                automatically if no file arguments are
                present).  This option has no effect when
                set after the shell has already started
                running (i.e. with set).

-V vi            Enable the built-in vi(1) command line
                editor (disables -E if it has been set).

-E emacs         Enable the built-in emacs(1) command line
                editor (disables -V if it has been set).

-b notify        Enable asynchronous notification of
                background job completion.  (UNIMPLEMENTED
                for 4.4alpha)

dash 命令实例:


dash 启动交互式 shell

dash

dash 执行一个命令:

dash -c "command"

dash 从文件运行命令:

dash file.sh

dash 从文件运行命令,将执行的所有命令记录到终端:

dash -x file.sh

dash 命令扩展阅读:




dash 命令评论