Shell shift procedure - What is this?

后端 未结 5 1783
天命终不由人
天命终不由人 2021-02-05 08:45

In shell we have the command shift, but i saw on some example its giving shift 3

Why there is a number after shift ? and what its about ? what it does ?

Example:

5条回答
  •  隐瞒了意图╮
    2021-02-05 09:09

    shift treat command line arguments as a FIFO queue, it popleft element every time it's invoked.

    array = [a, b, c]
    shift equivalent to
    array.popleft
    [b, c]
    $1, $2,$3 can be interpreted as index of the array.
    

    bash - The advantage of shift over reassign value straightforward - Stack Overflow

提交回复
热议问题