shell中shift的作用
请问在SHELL编程中SHIFT的作用是什么啊? 移除最左边的一个参数#!/usr/local/bin/bash
echo $@
shift
echo $@
$@ 表示所有的位置参数。
测试:
bash-2.05b# ./shift.sh 1 2 3 4
1 2 3 4
2 3 4
bash-2.05b#
也可左移n个参数
/home/lee#set a b c d e f g
/home/lee#shift 2;echo $*;shift 3;echo $*
c d e f g
f g 也可左移n个参数
/home/lee#set a b c d e f g
/home/lee#shift 2;echo $*;shift 3;echo $*
c d e f g
f g
长见识了,多谢kornlee大哥 :) 也可左移n个参数
/home/lee#set a b c d e f g
/home/lee#shift 2;echo $*;shift 3;echo $*
c d e f g
f g
长见识了,多谢kornlee大哥 :)
汗 #_! 顶了! :-)
页:
[1]