Shell special variables and forward and backward task switching methods

Source: Internet
Author: User

Echo ' $ Get the file name of the currently executing shell script: ' $

Echo ' $n gets the nth parameter value of the currently executing shell script: ' $ ' =$1 ' $ =$2 ' $ ' =$3

Echo ' $* gets all the parameters of the currently executing shell script: ' $*

Echo ' $ #获取当前执行的shell脚本的命令行中参数总个数: ' $#

Echo ' $$ Gets the process number (PID) of the currently executing shell script: ' $$

Sleep 2 &

Echo ' $! gets the PID that executes the previous instruction: ' $!

Echo ' $? Gets the return value of the last instruction executed: ' $?

Echo ' [email protected] Get all the parameters to take this program: ' [email protected]

Echo ' $_ The last parameter of the command or script executed before: ' $_


Linux before and after task switching method:

1, when the Linux terminal to run the command, at the end of the command to add & symbols, you can let the program run in the background

./TCPSERV01 &


2, if the program is running in the foreground, you can use the CTRL + Z option to suspend the program, and then use the BG%[number] command to put this program in the background to run

./tcpserv01

^z

[1]+ Stopped./tcpserv01

[Email protected]:~/unp/unpv13e/tcpcliserv$ bg%1

[1]+./TCPSERV01 &

[Email protected]:~/unp/unpv13e/tcpcliserv$


3, for all running programs, we can use the jobs–l command to view

[Email protected]:~/unp/unpv13e/tcpcliserv$ jobs-l

[1]+ 4524 Running./TCPSERV01 &


4, can also use FG%[number] command to drop a program to the foreground run

[Email protected]:~/unp/unpv13e/tcpcliserv$ FG%1

./tcpserv01


5, can also directly terminate the background running programs, using the KILL command

[Email protected]:~/unp/unpv13e/tcpcliserv$ kill%1


6,nohup Command, the original program's standard output is automatically redirected to the current directory of the Nohup.out file, played the role of log.

Nohup/root/start.sh &

Shell special variables and forward and backward task switching methods

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.