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)