linux shell脚本中shift命令的使用
2015-10-03 18:28
423 查看
1.shell脚本中的位置参数
shell脚本中的位置参数有两种:
一种是调用脚本时传给脚本的参数,另一种是调用脚本的函数时,传给函数的参数。
2.shift
shift可以用来向左移动位置参数。
使用方法:
shift num 将位置参数向左移动num个位置,默认情况下num为1.
举例说明:
shell脚本中的位置参数有两种:
一种是调用脚本时传给脚本的参数,另一种是调用脚本的函数时,传给函数的参数。
2.shift
shift可以用来向左移动位置参数。
使用方法:
shift num 将位置参数向左移动num个位置,默认情况下num为1.
举例说明:
#!/bin/bash function func_t(){ shift #将函数func_1的位置参数向左移动一位 echo $@ } shift #将脚本tmp.sh的位置参数向左移动一位 func_t ee rr ss echo $@ #使用sh tmp.sh 11 22 33来调用脚本,执行结果如下: rr ss 22 33
相关文章推荐
- Linux Shell学习笔记5:理解Linux文件权限
- Bash基础
- linux中shell脚本中的break|continue
- Linux Shell学习笔记4:使用Linux环境变量
- 快速排序——PowerShell版
- Linux Shell学习笔记3:更多的bash shell命令
- Linux Shell学习笔记2:基本的bash shell命令
- 系统管理员常用的Powershell命令
- Linux Shell学习笔记1:Linux入门
- centos shell基础 alias 变量单引号 双引号 history 错误重定向 2>&1 jobs 环境变量 .bash_history source配置文件 nohup & 后台运行 cut,sort,wc ,uniq ,tee ,tr ,split, paste cat> 2.txt <<EOF 通配符 glob模式 发邮件命令mail 2015-4-8 第十二节课
- linux,shell后台启动一个死循环程序不停输出信息,当关闭shell后重新打开为嘛没输出了
- <四>初识Bash
- [Linux.Shell] My Shell Tool - Support for UI CheckBox
- linux 几个简单shell脚本demo
- 常用 shell 脚本
- Putty和SSH Secure Shell简单设置
- Git windows下git bash显示中文
- 收集的55个Linux系统管理中常用的一些shell命令
- 使用Xshell连接Linux连接不上
- [Linux.Shell] 变量提取