1.配列定義
[chengmo @ centos5〜] $ a =(1 2 3 4 5)[chengmo @ centos5〜] $ echo $ a1
一対の括弧は配列を表し、配列要素は「スペース」記号で区切ります。
2.配列の読み取りと代入•長さを取得します。
[chengmo @ centos5〜] $ echo $ {#a [@]} 5
配列の長さを取得するには、$ {#配列名[@または*]}を使用します。
[chengmo @ centos5〜] $ echo $ {a [2]} 3
[chengmo @ centos5〜] $ echo $ {a [*]} 1 2 3 4 5
With $ {array name [添字]}添字は0から始まり、添字は:*または@配列の内容全体を取得•代入:
[chengmo @ centos5〜] $ a [1] = 100
[chengmo @ centos5〜] $ echo $ {a [*]} 1 100 3 4 5
[chengmo @ centos5〜] $ a [5] = 100 [chengmo @ centos5〜] $ echo $ {a [*]}
1 100 3 4 5 100
配列名[subscript]に直接参照を代入することができます添字が存在しない場合は、新しい配列要素を自動的に追加して• Delete:
[chengmo @ centos5〜] $ a =(1 2 3 4 5)[chengmo @ centos5〜] $未設定[chengmo @ centos5〜] $ echo $ {a [*]}
[chengmo @ centos5] 〜] $ a =(1 2 3 4 5)[chengmo @ centos5〜] $設定解除[1] [chengmo @ centos5〜] $ echo $ {a [*]} 1 3 4 5 [chengmo @ centos5〜] $エコー$ {#a [*]} 4
直接スルー:配列の設定解除[添え字]添字なしで、対応する要素をクリアするには、全データを消去します。
3.特殊用途&ブル;スライス:
[chengmo @ centos5〜] $ a =(1 2 3 4 5)[ ,null,null,3],Chengmo @ centos5〜] $ echo $ {a [@]:0:3} 1 2 3 [chengmo @ centos5〜] $ echo $ {a [@]:1:4} 2 3 4 5
[chengmo @ centos5〜] $ c =($ {a [@]:1:4})[chengmo @ centos5〜] $ echo $ {#c [@]} 4 [chengmo @ centos5〜] $ echo $ {c [*]} 2 3 4 5
直接$ {配列名[@または*]:開始位置:長さ}元の配列をスライスし、' space'で区切られた文字列を返します。したがって、'()'を追加すると、スライスされた配列になります上記の例では、cが新しいデータです。 •置換:
[chengmo @ centos5〜] $ a =(1 2 3 4 5)[chengmo @ centos5〜] $ echo $ {a [@] /3/100} 1 2 100 4 5 [chengmo @ centos5〜] $ echo $ {a [@]} 1 2 3 4 5 [chengmo @ centos5〜] $ a =($ {a [@] /3/100})[chengmo @ centos5〜] $ echo $ {a [@]} 1 2 100 4 5
呼び出しメソッドは以下のとおりです。上記の例を見て、データを再定義することができます。
上記から、Linuxシェルの配列は非常に強力であり、一般的な操作で十分すぎることがわかります。
RedHat Linuxは、システムセキュリティを向上させるためのファイアウォール保護を提供します。コンピュータとネットワークの間にファイアウォールが存在し、コンピュータ上のどのリソースにネットワーク
実際に読むときには、共有記憶領域の説明は役に立ちませんので、小さなプログラムを書いて、子プロセスを大まかに作成し、子プロセスはその文字列を端末から受け取り、共有領域に格納します。文字列を読み、それを
インストール手順 1、このインストールパッケージはAlibaba CloudのすべてのLinuxシステムにデプロイできます。このインストールパッケージのソフトウェアとバージョンは:nginx:1.0で