Shell Programming-Introduction (I.)

Source: Internet
Author: User
Tags chmod

1. Shell Concept
The shell is a program written in C, which is a bridge for users to use Linux
The shell is both a command voice and a programming voice
A shell is an application that provides an interface through which users access the operating system kernel's services

2. Shell Script
Shell script is the full name of shell scripts, a script written for the shell
Ken Thompson's SH is the first UNIX Shell

3. Shell Environment
Shell programming as long as there is a text editor that can write code and a script interpreter that interprets execution
The common shell types in Linux are:
Bourne Shell (/usr/bin/sh or/bin/sh)
Bourne Again Shell (/bin/bash)
Easy to use and free, bash is widely used in daily work
Bash is the default shell for most Linux systems
C Shell (/USR/BIN/CSH)
K Shell (/usr/bin/ksh)
Shell for Root (/sbin/sh)

In general, people do not differentiate between the Bourne shell and the Bourne Again shell, so, like #!/bin/sh, it can also be changed to #!/bin/bash

4. Shell function
A shell script that writes a number of commands together so that the user executes a file quickly, executing multiple commands at once


5. Bash Environment
. bash_profile
Setting environment variables
Once the account is established, there is

. BASHRC
To store commands for bash
Every boot is executed
Executed after the. bash_profile

. bash_logout
Run only when exiting the registration

. Bash_histroy
Historical records

6. Format
Format: VI filename.sh use VI to write shell scripts
Script First line format: #! /bin/bash
Symbol #! The parser that is used to specify the script file. When the script is edited, the execution script must also use its Executable property, that is: chmod+x filename and then execute./filename.sh
The second method of execution:/bin/bash filename.sh

7. Precautions
Chmod+x file plus execute permission, otherwise you will be prompted for no EXECUTE permission
When executing a script or full directory, or,./file.sh, if not added, Linux defaults to find file.sh from path
After the script suffix is modified, it will still work

Shell Programming-Introduction (I.)

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.