zoukankan      html  css  js  c++  java
  • Bash Shell中Shift用法分享

    这篇文章主要介绍了Bash Shell中Shift的使用方法,需要的朋友可以参考下

    shift可以用来向左移动位置参数。
    Shell的名字 $0
    第一个参数 $1
    第二个参数 $2
    第n个参数 $n
    所有参数 $@ 或 $*
    参数个数 $#

    shift默认是shift 1
    例:

    #----------------------------输出文字-开始----------------------------
    #!/bin/bash
    #Filename: shift.sh 
    #by www.jbxue.com
    until [ -z "$1" ] # Until all parameters used up
    do
    echo "$@ "
    shift
    done
    #----------------------------输出文字-结束----------------------------
    
    sh shift.sh 1 2 3 4 5 6 7 8 9
    #----------------------------输出文字-开始----------------------------
    1 2 3 4 5 6 7 8 9
    2 3 4 5 6 7 8 9
    3 4 5 6 7 8 9
    4 5 6 7 8 9
    5 6 7 8 9
    6 7 8 9
    7 8 9
    8 9
    9
    #----------------------------输出文字-结束----------------------------
  • 相关阅读:
    hlgoj 1766 Cubing
    Reverse Linked List
    String to Integer
    Bitwise AND of Numbers Range
    Best Time to Buy and Sell Stock III
    First Missing Positive
    Permutation Sequence
    Next Permutation
    Gray Code
    Number of Islands
  • 原文地址:https://www.cnblogs.com/cfinder010/p/3234069.html
Copyright © 2011-2022 走看看