19

私はUnixにまったく慣れていません。現在、 KornShell (ksh)Bash shell の両方について学ぶように依頼されています。この 2 つについて簡単に説明していただけますか。

「シェル」という用語は「ターミナル」と同義ですか?

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

4

2 に答える 2

29

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.
于 2013-10-01T09:08:47.620 に答える
4

ksh にはオープン ソース バージョンがあります。Linux で実行できます。pdksh と呼ばれる OSS 用の古い 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.
于 2013-10-01T09:20:16.403 に答える