Some arguments are used in the Bash Shell,
$1,$2,... A specific number of parameters, the name of the currently executing process name, the script itself, or the whole row output in a regular expression
$# the command line or the number of positional arguments
$* all positional parameters, being used as a word.
$@ is synonymous with $*, but each argument is a separate "" reference string, which means that the parameter is passed in full
$-passed to the script Falg
$! The PID (process ID) of the last work running in the background.
$_ the last parameter of the command that was executed before it was saved.
$? function, or the exit state of the script itself, to check whether the previous command, function, or script was executed correctly. (0 indicates that the command executes correctly, and any non-0 value indicates a command error.) )
$$ The process ID of the script itself.
Use examples:
Execute statement Run Result:
[Root@myhost tmp]#./filelist.sh file1.txt file2.txt file3.txt General
file list Files:3 general by
:./filelist. SH Last
command:last PID: are
normal:0 current
pid:26418
Filelist.txt:
[Root@myhost tmp]# cat filelist.txt
Param1:file1.txt
Param2:file2.txt all
param:file1.txt file2.txt File3.txt all
param:file1.txt file2.txt file3.txt
FLAG:HB last
PID:
filelist.sh
[Root@myhost tmp]# cat filelist.sh
#!/bin/bash
echo General file List files: $# '
echo ' General by: $ "
E Cho "Param1: $ > Filelist.txt
echo" PARAM2: $ >> filelist.txt
echo "all param: $*" >> filelist. TXT
echo "All param: $@" >> filelist.txt
echo "Flag: $-" >> filelist.txt
echo "Last PID: $!" >& Gt Filelist.txt
echo "Last command: $_"
echo "is normal: $?"
echo "Current PID: $$"
This article from the "Small Hebebe Technical Space" blog, please be sure to keep this source http://babyhe.blog.51cto.com/1104064/322297
See more highlights of this column: http://www.bianceng.cnhttp://www.bianceng.cn/OS/unix/