• <ruby id="5koa6"></ruby>
    <ruby id="5koa6"><option id="5koa6"><thead id="5koa6"></thead></option></ruby>

    <progress id="5koa6"></progress>

  • <strong id="5koa6"></strong>
  • Linux程式設計-11.Shell Script(bash)--(2)教學例

    發表于:2007-07-01來源:作者:點擊數: 標簽:
    "Hello world" Shell Script 照傳統程式教學例,這一節介紹Shell Script的"Hello World"如何撰寫。 -------------------------------------------------------------------------------- #!/bin/sh # Filename : hello echo "Hello world!" -----------------
    "Hello world" Shell Script
    照傳統程式教學例,這一節介紹Shell Script的"Hello World"如何撰寫。



    --------------------------------------------------------------------------------

    #!/bin/sh
    # Filename : hello
    echo "Hello world!"

    --------------------------------------------------------------------------------

    大家應該會注意到第一行的"#!/bin/sh"。在UNIX下,所有的可執行Script,不管是那一種語言,其開頭都是"#!",例如Perl是"#!/usr/bin/perl",tcl/tk是"#!/usr/bin/wish",看您要執行的Script程式位置在那里。您也可以用"#!/bin/bash"、"#!/bin/tcsh"等等,來指定使用特定的Shell。
    echo是個bash的內建指令。



    --------------------------------------------------------------------------------

    接下來,執行hello這個script:
    要執行一個Script的方式有很多種。



    --------------------------------------------------------------------------------

    第一種 : 將hello這個檔案的權限設定為可執行。
    [foxman@foxman bash]# chmod 755 hello
    執行
    [foxman@foxman bash]# ./hello
    hello world



    --------------------------------------------------------------------------------

    第二種 : 使用bash內建指令"source"或"."。
    [foxman@foxman bash]# source hello
    hello world

    [foxman@foxman bash]# . hello
    hello world



    --------------------------------------------------------------------------------

    第三種 : 直接使用sh/bash/tcsh指令來執行。
    [foxman@foxman bash]# sh hello
    hello world

    [foxman@foxman bash]# bash hello
    hello world



    --------------------------------------------------------------------------------

    Bash執行選項

    --------------------------------------------------------------------------------

    -c string : 讀取string來當命令。
    -i : 互動介面。
    -s : 由stdin讀取命令。
    - : 取消往後選項的讀取。
    -norc : 不要讀~/.bashrc來執行。
    -noprofile : 不要讀/etc/profile、~/.bash_profile、~/.bash_login、~/.profile等等來執行。
    -rcfile filename : 執行filename,而非~/.bashrc
    -version : 顯示版本。
    -quiet : 啟動時不要哩唆。
    -login : 確保bash是個login shell。
    -nobraceexpansion : 不要用curly brace expansion({}符號展開)。
    -nolineediting : 不用readline來讀取命令列。
    -posix : 改采Posix 1003.2標準。

    原文轉自:http://www.kjueaiud.com

    老湿亚洲永久精品ww47香蕉图片_日韩欧美中文字幕北美法律_国产AV永久无码天堂影院_久久婷婷综合色丁香五月

  • <ruby id="5koa6"></ruby>
    <ruby id="5koa6"><option id="5koa6"><thead id="5koa6"></thead></option></ruby>

    <progress id="5koa6"></progress>

  • <strong id="5koa6"></strong>