shell中$@和$*的区别
来源:互联网 发布:试客系统整站源码 编辑:程序博客网 时间:2024/04/30 02:55
$*
所有的位置参数,被作为一个单词.
注意:“$*”必须被”“引用.
$@
与
双引号括起来的情况:
#!/usr/bin/env bash:<<EOF运行结果如下:root@kali:~/.pyenv# /bin/bash asterisk_and_at.sh 1 2 3 4 5 "hello world"Listing args with "$*": Arg #1=1 2 3 4 5 hello world所有的参数均认为是一个Listing args with no double quoto $\*(没有被引用)Arg #1=1Arg #2=2Arg #3=3Arg #4=4Arg #5=5Arg #6=helloArg #7=world所有的参数被认为是各个独立的单词Listing args with "$\@": Arg #1=1Arg #2=2Arg #3=3Arg #4=4Arg #5=5Arg #6=hello worldListing args with $\@(没有被引用): Arg #1=1Arg #2=2Arg #3=3Arg #4=4Arg #5=5Arg #6=helloArg #7=worldEOFset -e#set -xindex=1echo "Listing args with \"\$*\": "for arg in "$*"; do echo "Arg #$index=$arg" let index+=1doneecho -e "所有的参数均认为是一个\n"index=1echo "Listing args with no double quoto \$\*(没有被引用)"for arg in $*; do echo "Arg #$index=$arg" let index+=1doneecho -e "所有的参数被认为是各个独立的单词\n"index=1echo -e "Listing args with \"\$\@\": "for arg in "$@"; do echo "Arg #$index=$arg" let index+=1doneecho index=1echo "Listing args with \$\@(没有被引用): "for arg in $@; do echo "Arg #$index=$arg" let index+=1doneecho exit 0中
参考:http://blog.csdn.net/zhejiang9/article/details/7887569
0 0
- shell中$@和$*的区别
- shell中“>”和“>>”的区别
- shell中$@和$*区别
- [Linux]: shell中[]和[[]]的区别
- shell中()和{}的区别
- unix shell中(),[]和[[]]的区别
- Shell中反引号和$()的区别
- linux shell中'',""和``的区别
- Shell中exec、source和shell script的区别
- Shell中exec、source和shell script的区别
- linux:Shell中exec、source和shell script的区别
- linux:Shell中exec、source和shell script的区别
- [Shell]shell中./和source的区别(…
- shell中“ “ ” ” ‘ “ ” ' “的区别
- shell中$*,$@,$# 的区别
- shell ' ', " " 和 `` 的区别
- VB中Shell和ShellExecute函数的使用方法和区别
- shell 脚本中getopt 和 getopts 的区别
- USACO 3.1 Humble Numbers丑数
- 简单的贴图融合
- [工具]VS2013下载地址
- IQKeyboardManager简单实用
- HDU 1003 最大连续子段和
- shell中$@和$*的区别
- 5.Git代码<安装与配置>-2(自我整理) 2016/11/12
- 火力点
- 最优化方法综述
- [转]swift, unwind segue回传数据
- 又上锁妖塔
- 从零开始学习OpenWrt完美教程+学习笔记
- less封装累积
- linux查看文件创建修改时间,如何显示年份