`
yaojingguo
  • 浏览: 202227 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

Special shell variables

 
阅读更多
$1 - $9       these variables are the positional parameters.

$0            the name of the command currently being executed.

$#            the number of positional arguments given to this
              invocation of the shell.

$?            the exit status of the last command executed is
              given as a decimal string.  When a command
              completes successfully, it returns the exit status
              of 0 (zero), otherwise it returns a non-zero exit
              status.

$$            the process number of this shell - useful for
              including in filenames, to make them unique.

$!            the process id of the last command run in
              the background.

$-            the current options supplied to this invocation
              of the shell.

$*            a string containing all the arguments to the
              shell, starting at $1.

$@            same as above, except when quoted.


Notes

$* and $@ when unquoted are identical and expand into the arguments.

"$*" is a single word, comprising all the arguments to the shell, joined together with spaces. For example '1 2' 3 becomes "1 2 3" .

"$@" is identical to the arguments received by the shell, the resulting list of words completely match what was given to the shell. For example '1 2' 3 becomes "1 2" "3"

分享到:
评论

相关推荐

    Linux高级bash编程

    Special Shell Variables B-2. TEST Operators: Binary Comparison B-3. TEST Operators: Files B-4. Parameter Substitution and Expansion B-5. String Operations B-6. Miscellaneous Constructs C-1. Basic sed...

    Advanced Bash-Scripting Guide <>

    Special Shell Variables B-2. TEST Operators: Binary Comparison B-3. TEST Operators: Files B-4. Parameter Substitution and Expansion B-5. String Operations B-6. Miscellaneous Constructs C-1. Basic sed...

    beginning_portable_shell_scripting_from_novice_to_professional.pdf

    Introducing Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .14 Introducing Quoting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ...

    ABS shell编程最新版

    Shell Programming! .........................................................................................................................1 Chapter 2. Starting Off With a Sha-Bang.....................

    Wiley.Publishing.Fedora.Linux.Toolbox.1000+.Commands.for.Fedora.CentOS.and.Red.Hat.Power.Users.and.Red.Hat.Power.Users.2008.pdf

    Chapter 1: Starting with Fedora Linux ....Appendix B: Shell Special Characters and Variables . . . .271 Appendix C: Getting Information from /proc . . . . . .275 Index . . . . . . . . . . . . . . 281

    2009 达内Unix学习笔记

    各个 shell 可互相切换 ksh:$ sh:$ csh:guangzhou% bash:bash-3.00$ 一、注意事项 命令和参数之间必需用空格隔开,参数和参数之间也必需用空格隔开。 一行不能超过256个字符;大小写有区分。 二、特殊字符...

    [精典材料]Patran的PCL用户手册.doc

    To get an element property value (shell thickness) for a specific element 150 To get a material property value 152 To get a list of all groups 153 To get the nodes and elements associated to the ...

    Debugging with GDB --2002年5.11

    r Shell commands GDB Commands r Command syntax r Command completion r Getting help Running Programs Under GDB r Compiling for debugging r Starting your program r Your program's arguments r Your ...

    PowerShellPack

    About_automatic_variables.help.txt About_break.help.txt About_command_search.help.txt About_command_syntax.help.txt About_comparison_operators.help.txt About_continue.help.txt About_core_commands.help...

    The Art of Assembly Language Programming

    Memory Layout and Access 4.0 - Chapter Overview 4.1 - The 80x86 CPUs:A Programmer's View 4.1.1 - 8086 General Purpose Registers 4.1.2 - 8086 Segment Registers 4.1.3 - 8086 Special ...

    Beginning Python (2005).pdf

    xvii Contents Finishing Your Modules 154 Defining Module-Specific Errors 154 Choosing What to Export ...CGI’s Special Environment Variables 471 Accepting User Input through HTML Forms 473 The cgi ...

    unix power tools

    1.1 What's Special About UNIX?............................................................................................................2 ...............................................................

    UNIX环境高级编程(第二版,英文版)

    Shell Execution of Programs Section 9.10. Orphaned Process Groups Section 9.11. FreeBSD Implementation Section 9.12. Summary Exercises Chapter 10. Signals Section 10.1. ...

    UNIX环境高级编程英文第三版+源码

    9.9 Shell Execution of Programs 303 9.10 Orphaned Process Groups 307 9.11 FreeBSD Implementation 310 9.12 Summary 312 Chapter 10. Signals 313 10.1 Introduction 313 10.2 Signal Concepts 313 10.3 signal...

    Python Cookbook, 2nd Edition

    Delegating Special Methods in Proxies Recipe 6.7. Implementing Tuples with Named Items Recipe 6.8. Avoiding Boilerplate Accessors for Properties Recipe 6.9. Making a Fast Copy of an Object ...

    abs-guide----Advanced Bash-Scripting Guide

    一本深入学习shell脚本艺术的书籍 非常好的书 强烈推荐 附有超多实例 Advanced Bash-Scripting Guide............................................................................................................

    python3.6.5参考手册 chm

    Operators And Special Methods Builtins Build and C API Changes Performance Porting To Python 3.0 What’s New in Python 2.7 The Future for Python 2.x Changes to the Handling of Deprecation ...

    Mpeg2_Decoder

    The directory verify/ contains a small set of verification pictures, a small bitstream, and Unix shell script to automatically test the output of the encoder and decoder. &lt;br&gt;A precompiled ...

    ak2新版内核AKAIO1.5

    + Leapyear code fixed because the DS sucks at reporting variables nicely. + Updated German language (moviecut). + Reset more of arm7 before runing a game (Thanks Gelu). + 3in1+ Fix for Opera (Untested...

Global site tag (gtag.js) - Google Analytics