#每日Linux小练习 #06 Shell Script Note Summary

Source: Internet
Author: User
Tags date1

Shell Script pros and cons analysis

The shell uses external commands and some of the default tools of the bash shell, so it often calls an external library of functions, so the command cycle is less than the traditional programming language.

Therefore, Shell script is good for system Management , but it is slower when dealing with a large number of numerical computations .

Considerations for Shell Script writing

1. If one line is too much, you can use \[enter] to extend to the next line

2. # can be used as an annotation

How to execute Script

1, direct command execution (to have readable executable permissions)

Absolute path, relative path, variable path function (e.g. ~/bin/)

2. Execution in bash process

such as bash shell.sh, sh shell.sh, source shell.sh

The same as the usual, in the practice of learning

Echo-E"I'll use the ' touch ' command to create 3 files"Read-P"Please input your filename"Fileuserfilename=${fileuser:-"filename"}date1=$(Date--Date='2 days ago'+%y%m%d) Date2=$(Date--Date='1 days ago'+%y%m%d) Date3=$(Date+%y%m%d) File1=${filename}${date1}file2=${filename}${date2}file3=${filename}${date3}Touch "$file 1"Touch "$file 2"Touch "$file 3"

1. Basic usage of Read

2, date1=$ (date--date= ' 2 days ago ' +%y%m%d), use the command in $ () to get information

3. filename=${fileuser:-"filename"} involves "test and content substitution of variables"

Echo -e  "youshould input 2 numbers, I'll cross them""   /c7> "" "Secondnumbertotal =$ (($firstNumber *$ Secondnumber))echo"\ n The result of $firstNumber X $secondNumber is ==> $total "

1, var=$ (Operation content)

#每日Linux小练习 #06 Shell Script Note Summary

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.