Shell Programming----Notes

Source: Internet
Author: User

    • Consider the next, just own a little record, according to their own situation to record it, follow up with new things to add at any time. Oh, yes.

First, getting started with common sense

1. Several commands

1)!n: Executable nth command in history

    

2) Set: View all environment variables

3) Env: can view the current environment variables

4) unset (environment variable) (note: If the environment variable is defined in the parent process, the variable cannot be deleted in the child process

5) Alias: Alias, simple set up your command, the following using alias to implement a simple HTTP service

      

The effect is similar:

      

Note: If you need to set the restart is still in effect, you can write alias to ~/.BASHRC this is the same as setting ~/.VIMRC, requires immediate effect please use the source (.) ~/.BASHRC

      

6) WC: Statistic Quantity

Common options:

-L (line): Count rows

-M (chars): Count characters

-W (words): Number of statistical words

Like what:

      

Test Case:

1 # !/bin/bash 2 " number of rows: " 3 echo $ (WC-l test.txt)  4" number of characters:"5 echo $ (WC-
   
    m test.txt)  
    6
    " 
    number of words:
    "
    7 echo $ (wc-w test.txt)                
   

Output:

     

7) Sort: sort

8) Cut: Cut characters by format

9) printf: printing

Uniq: To repeat the line

One) TR: replace character (or use SED)

Split:    

SED: See the following simple regular expression description

AWK: See the following simple regular expression description

2. Set path, command (library) lookup paths

1) Assume that the test.sh is created under the/home/test/path

1 # !/bin/bash 2 " run successfully, set path successfully! "      

2) 1. Modify the permissions of test: chmod +x test.sh;

2. Set path= "$PATH": "$PWD"

3.echo $PATH View the results of our settings

Without an accident, you can see the result:

3) Setup succeeds, you can go to any path, execute test.sh

3. Redirection instructions

4. Operator description

5. Several special variables

6.Test

7. Get the result of the command in the shell

8. Simple Regular Expressions

9.shell syntax

1) variables

2) Process Control

3) function

1. Simple functions

2. With the parameter function

4) file contains

    

    • Resources:
    • Http://www.imooc.com/u/279399/courses?sort=publish (VIDEO)
    • Http://c.biancheng.net/cpp/view/6994.html
    • http://www.92csz.com/study/linux/

Shell Programming----Notes

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.