web-dev-qa-db-ja.com

kornシェルとbashシェルの違い

私は、Unixを初めて使用します。現在、私はKornShell(ksh)Bash Shellの両方について学ぶように頼まれています。誰かが2つについて簡単な概要を教えてもらえますか?

Shell」という用語は「terminal」と同義ですか?

私は両方のオンラインに関するドキュメントを読むことができることを理解しています。しかし、経験豊富なUnixプログラマーからの概要は、私がよりよく理解するのに役立つと信じています。

16
Programmer

UNIX.COMからの投稿

シェル機能

次の表は、あるシェルを別のシェルよりも選択すると思われるほとんどの機能を示しています。これは最終的なリストを意図したものではなく、可能なシェルごとに可能な機能がすべて含まれているわけではありません。機能は、オペレーティングシステムに付属のバージョンにある場合、または標準ディストリビューションから直接コンパイルされた状態で使用可能な場合にのみ、シェルにあると見なされます。特に、以下に指定されているCシェルはSUNOS 4. *で利用可能なものであり、かなりの数のベンダーがtcshまたは独自の拡張Cシェルを代わりに出荷しています(tcshを出荷していることを常に明確にするとは限りません)。

コード:

                                     sh   csh  ksh  bash tcsh zsh  rc   es
Job control                          N    Y    Y    Y    Y    Y    N    N
Aliases                              N    Y    Y    Y    Y    Y    N    N
Shell functions                      Y(1) N    Y    Y    N    Y    Y    Y
"Sensible" Input/Output redirection  Y    N    Y    Y    N    Y    Y    Y
Directory stack                      N    Y    Y    Y    Y    Y    F    F
Command history                      N    Y    Y    Y    Y    Y    L    L
Command line editing                 N    N    Y    Y    Y    Y    L    L
Vi Command line editing              N    N    Y    Y    Y(3) Y    L    L
Emacs Command line editing           N    N    Y    Y    Y    Y    L    L
Rebindable Command line editing      N    N    N    Y    Y    Y    L    L
User name look up                    N    Y    Y    Y    Y    Y    L    L
Login/Logout watching                N    N    N    N    Y    Y    F    F
Filename completion                  N    Y(1) Y    Y    Y    Y    L    L
Username completion                  N    Y(2) Y    Y    Y    Y    L    L
Hostname completion                  N    Y(2) Y    Y    Y    Y    L    L
History completion                   N    N    N    Y    Y    Y    L    L
Fully programmable Completion        N    N    N    N    Y    Y    N    N
Mh Mailbox completion                N    N    N    N(4) N(6) N(6) N    N
Co Processes                         N    N    Y    N    N    Y    N    N
Builtin artithmetic evaluation       N    Y    Y    Y    Y    Y    N    N
Can follow symbolic links invisibly  N    N    Y    Y    Y    Y    N    N
Periodic command execution           N    N    N    N    Y    Y    N    N
Custom Prompt (easily)               N    N    Y    Y    Y    Y    Y    Y
Sun Keyboard Hack                    N    N    N    N    N    Y    N    N
Spelling Correction                  N    N    N    N    Y    Y    N    N
Process Substitution                 N    N    N    Y(2) N    Y    Y    Y
Underlying Syntax                    sh   csh  sh   sh   csh  sh   rc   rc
Freely Available                     N    N    N(5) Y    Y    Y    Y    Y
Checks Mailbox                       N    Y    Y    Y    Y    Y    F    F
Tty Sanity Checking                  N    N    N    N    Y    Y    N    N
Can cope with large argument lists   Y    N    Y    Y    Y    Y    Y    Y
Has non-interactive startup file     N    Y    Y(7) Y(7) Y    Y    N    N
Has non-login startup file           N    Y    Y(7) Y    Y    Y    N    N
Can avoid user startup files         N    Y    N    Y    N    Y    Y    Y
Can specify startup file             N    N    Y    Y    N    N    N    N
Low level command redefinition       N    N    N    N    N    N    N    Y
Has anonymous functions              N    N    N    N    N    N    Y    Y
List Variables                       N    Y    Y    N    Y    Y    Y    Y
Full signal trap handling            Y    N    Y    Y    N    Y    Y    Y
File no clobber ability              N    Y    Y    Y    Y    Y    N    F
Local variables                      N    N    Y    Y    N    Y    Y    Y
Lexically scoped variables           N    N    N    N    N    N    N    Y
Exceptions                           N    N    N    N    N    N    N    Y

上記の表の要点

Yこのシェルを使用して機能を実行できます。

N機能はシェルに存在しません。

F機能は、シェル関数メカニズムを使用してのみ実行できます。

Lこの機能を有効にするには、readlineライブラリをシェルにリンクする必要があります。

上記の表の注

1. This feature was not in the original version, but has since become
   almost standard.
2. This feature is fairly new and so is often not found on many
   versions of the Shell, it is gradually making its way into
   standard distribution.
3. The Vi emulation of this Shell is thought by many to be
   incomplete.
4. This feature is not standard but unofficial patches exist to
   perform this.
5. A version called 'pdksh' is freely available, but does not have
   the full functionality of the AT&T version.
6. This can be done via the shells programmable completion mechanism.
7. Only by specifying a file via the ENV environment variable.
27
SriniV

Kshにはオープンソースバージョンがあります。 Linuxで実行できます。 OSSにはpdkshと呼ばれる古いkshがありましたが、これは新しいkshとは多少異なる動作をするため、人々がそれを好まなかったのかもしれません。

いくつかの違いがあります-bashにはkshの機能の大部分があり、それからいくつかの追加機能があります。 kshで実行するように記述されたスクリプトは、bashで正常に実行される可能性があります。多くの違いは数学、変数、配列、関数などに関係します-bashはkshよりもはるかに多くのものを持っているようです

ksh is available on multiple platforms by default but bash would have to be specifically added. On the flip side though, most Linux distros come with bash and you have to add ksh if you want it.

Kshがデフォルトで使用するがbashではないviスタイルの編集。ただし、bashで「set -o vi」と入力して同じ機能を取得できます。

one reason for using ksh for scripting is, this Shell is available on nearly all existing flavours of *nix. Bash is not installed by default on all *nix.
4
sTg