HereDoc (Here Document) Usage

风行水上 @ 2014-12-16 18:33:21
标签:

    Bash Shell

    #!/bin/bash
    
    abc=123
    
    # 变量被替换
    tclsh <<__CODE__
    set abc 456
    puts $abc
    exit
    __CODE__
    
    # 没有变量替换
    tclsh <<'__CODE__'
    set abc 456
    puts $abc
    exit
    __CODE__
    
    # 结尾处**没有**单引号
    
    echo 789
    
    # Here String
    
    tr a-z A-Z <<< "hello world"
    

    C Shell

    #!/bin/csh -f
    
    set abc = 123
    
    # 变量被替换
    tclsh <<__CODE__
    set abc 456
    puts $abc
    exit
    __CODE__
    
    # 没有变量替换
    tclsh <<'__CODE__'
    set abc 456
    puts $abc
    exit
    '__CODE__'
    
    # 结尾处**有**单引号
    
    echo 789
    
    # Here String Simulate in C Shell
    
    echo "hello world" | tr a-z A-Z
    
    标签:

      分享到:
      comments powered by Disqus

      36/18ms