Chapter 6 of linuxshell programming guide ------ shell script introduction

Source: Internet
Author: User
A shell script can contain one or more commands. Of course, you don't have to write a shell script for just two commands. you have to decide everything. A shell script can receive information in a command and use it as the input of another command. One s h e l script can contain one or more commands. Of course, you don't have to write one s h e l for just two commands.

Script. it is up to the user to decide everything.

The s h e l script can receive information in the line command and use it as the input of another command.

A script is not a complex program. it is interpreted by line. The first line of the script always starts #! /B I n/s h, this script notification starts
S h e l uses the Bourne shell interpreter on the system.

Any script may have comments. The first character of this line is #. the interpreter will not explain this line. Writing a script name in the second line of comment is a good habit.

Run the script from top to bottom. you need to grant the execution permission before running the script. Make sure that the script path is created correctly.
Run it with the file name.

You can use the c h m o d command to increase the script execution permission.
$ Chmod u + x cleanup
Run the script now. just enter the file name.
$ Cleanup
If an error message is returned:
$ Cleanup
Sh: cleanup: command not found
Try again:
$./Cleanup
If you must enter the path name before running the script, or the command cannot be found in the s h e l result notification, you need
Add the user executable program directory under pat h. To ensure that the user is in the $ h o m e executable program directory, enter:
$ Pwd
$/Home/dave/bin
If the last part of the p w d command is B I n, add this information to the path. Edit the user. p r o f I l e file,
Add the executable program directory $ h o m e/B I n as follows:
P a t h = $ p a t h: $ h o m e/B I n
If there is no B I n Directory, create it. First, make sure that it is in the root directory of the user.
$ Cd $ HOME
$ Mkdir bin
Now we can add the "B I n" directory to the "pat h" variable in the. p r o f I l e file, and re-initialize. p r o f I l e.
$ ../Profile
The script runs normally.

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.