[[email protected] ~]# mkdir shell[[email protected] ~]# cd shell/[[ email protected] shell]# vim first.sh#!/bin/bash must be # #the first test shell script. Description # #written by guozhen.mkdir 123 Create a 123ls and displays the file under the LS directory echo "this Is the first script. "
How do you do it? Two methods
First Kind
[Email protected] shell]# Bash first.sh111 123 First.shthis is the first script.
The second Kind
[[email protected] shell]# chmod a+x first.sh plus permissions [[email protected] shell]#./first.shmkdir:cannot Create directory ' 123 ' : File exists111 123 First.shthis is the first script.
You can also use absolute paths
[Email protected] shell]#/root/shell/first.sh111 123 First.shthis is the first script.
can also be executed with SH
[Email protected] shell]# SH first.sh111 123 First.shthis is the first script.
To view the execution of a script (errors can be traced)
[[email protected] shell]# sh-x first.sh+ mkdir 123mkdir:cannot Create directory ' 123 ': File exists+ ls111 123 First.s H + echo ' This is the first script. ' This is the first script.
This article is from "Linux rookie" blog, please be sure to keep this source http://490617581.blog.51cto.com/11186315/1764394
Shell script structure and execution methods