Linux Bash Learning (i)

Source: Internet
Author: User

1. Please write a script for the purpose of the read instruction, he can let the user input: 1. First name with 2. Last name, finally and on the screen: "Your full name is:" Content:

 #!/bin/bash#program:# use input his first name and  last   name. Program shows he full name #History: #  2017 /     07 /27   Lzyer releaseread -P  " please input your First Name:    firstnameread -P  " please input your last name:  "   lastname  echo   " your full name is: ${firstname}.${lastname}   " 

2. Change with date: creation of files using date

#!/bin/bash#program:# program creates three files,whichNamed by user's input and date command.#History # ./ -/ -Lzyer First releaseEcho "I'll use the ' touch ' command to create 3 file."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 "${file1}" "${file2}" "${file3}"

3. Numerical operation: Simple subtraction

#!/bin/bash#program:# Use input2The integer numbers; program would cross these the numbers. #History: # ./ -/ -Lzyer First releaseEcho "You should input 2 numbers, I'll multipfying them!"Read-P"First Numbe:"Firstnumberread-P"Second Number:"Secondnumbertotal=$ ((${firstnumber}*${secondnumber}))Echo "The result of ${firstnumber} x ${secondnumber} ==> ${total}"

Differences in 4.sh and source

Linux Bash Learning (i)

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.