zoukankan      html  css  js  c++  java
  • learning shell built-in variables (1)

    Shell built-in variables

    Purpose

           Learning shell built-in variables, example $0,$1,$2,$3,$#,$$,$*,$@,$-,$?

     

    Eevironment

           Ubuntu 16.04 bash env

     

    Procdeure

    Source code:

    #!/bin/bash
    
    echo "shell args option"
    echo "script name : $0"
    echo "first args : $1"
    echo "first args : $2"
    echo "first args : $3"
    
    echo "------- $# demonstration"
    echo "args number: $#"
    
    
    echo "------- $$ demonstration"
    echo "shell pid: $$"
    
    echo "------- $* demonstration"
    for i in "$*";do
    echo $i
    done
    
    echo "------- $@ demonstration"
    for i in "$@";do
    echo $i
    done
    
    echo "------- $- demonstration"
    echo $-

    $ ./test.sh 1 2 3
    shell args option
    script name : ./test.sh
    first args : 1
    first args : 2
    first args : 3
    ------- $# demonstration
    args number: 3
    ------- $$ demonstration
    shell pid: 12263
    ------- $* demonstration
    1 2 3
    ------- $@ demonstration
    1
    2
    3
    ------- $- demonstration
    hB


    vmuser@vmuser-virtual-machine:~/shell$ echo $?
    0

  • 相关阅读:
    LeetCode
    LeetCode
    LeetCode
    LeetCode
    LeetCode
    LeetCode
    LeetCode
    LeetCode
    LeetCode
    codevs 1501 二叉树最大宽度和高度x
  • 原文地址:https://www.cnblogs.com/lianghong881018/p/10314026.html
Copyright © 2011-2022 走看看