Shell Script Programming Basics

Source: Internet
Author: User
Tags echo command

1. Create shell script file     Create file, add executable permission to file chmod +x file    format: Specify the shell        #! in the first line of the file /bin/bash    NOTES: #开头的命令 (except  #!/bin/bash  in the first line)     Display message: Echo command         Quotation marks are not required by default, and if you need to display a string that contains one of the single or double quotation marks, you can use a different string to make the difference.         echo command displays the string after the default line wrap, the-n option can be executed after the result of the next line of command is displayed         The environment variable reference in ECHO is automatically recognized and replaced with the actual value  $ (variable name)     User variable:        format: name=value, no spaces in the middle, The life cycle is the execution of the shell script, and the automatic deletion is done.     Back quotes ('): Gets the return content of the command to be executed         such as: times= ' Date '            &NBS P    echo "The data is:" $times                the data Is:mon Jan 31 20:2 3:25 EDT 2011    REDIRECT:        OUTPUT redirect: command > OutputFile  --overwrite write to file     &NB Sp                        command >> outputfile --Append to file         input redirection: Opposite to output redirection, using < or &LT;&LT, less common     piping: | , for the output of one command as input to another command, two commands for simultaneous execution 2, exit script     View exit status code: $? Saved the result of the previous command execution, 0 for success, 1~255 for error         Common status code--126: no permissions; 127: Command not found     Exit command: Exit status code, Used to exit the shell script and specify an exit code

Shell Script Programming Basics

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.