#!/bin/bash
read -p "Please input your first name:" firstname
read -p "Please input your last name:" lastname
echo "Your full name is:$firstname $lastname"
#!/bin/bash
echo "I will use touch command to create 3 files."
read -p "Please input your filename:" fileuser
filename=${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"
touch "$file2"
touch "$file3"
#!/bin/bash
echo "You should input 2 numbers,, I will cross them!"
read -p "first number:" firstnu
read -p "second number:" secondnu
total=$(($firstnu * $secondnu))
echo "The result of $firstnu * $secondnu is ==> $total"
#!/bin/bash
echo "Please input a filename, I will check the filename's type and permission."
read -p "Input a filename:" filename
test -z $filename && echo "You must input a filename." && exit 0
test ! -e $filename && echo "The filename '$filename' do not exist" && exit 0
test -f $filename && filetype="regulare file"
test -d $filename && filetype="directory"
test -r $filename && perm="readable"
test -w $filename && perm="$perm writable"
test -x $filename && perm="$perm executable"
echo "The filename:$filename is a $filetype"
echo "And the permissions are:$perm"
#!/bin/bash
read -p "Please input(Y/N):" yn
[ "$yn" == "Y" -o "$yn" == "y" ] && echo "OK, continue" && exit 0
[ "$yn" == "N" -o "$yn" == "n" ] && echo "Oh, interrupt!" && exit 0
echo "I don't know what your choice is" && exit 0
#!/bin/bash
read -p "Please input(Y/N):" yn
if [ "$yn" == "Y" ] || [ "$yn" == "y" ]; then
echo "OK, continue"
exit 0
fi
if [ "$yn" == "N" ] || [ "$yn" == "n" ]; then
echo "Oh, interrupt!"
exit 0
fi
echo "I don't know what your choice is" && exit 0
#!/bin/bash
read -p "Please input(Y/N):" yn
if [ "$yn" == "Y" ] || [ "$yn" == "y" ]; then
echo "OK, continue"
elif [ "$yn" == "N" ] || [ "$yn" == "n" ]; then
echo "Oh, interrupt!"
else
echo "I don't know what your choice is"
fi
#!/bin/bash
echo "The script name is ==> $0"
echo "Total parameter number is ==> $#"
[ "$#" -lt 2 ] && echo "The number of parameter is less than 2. Stop here." && exit 0
echo "Your whole parameter is ==> '$@'"
echo "The 1st parameter ==> $1"
echo "The 2nd parameter ==> $2"
#!/bin/bash
echo "Total parameter number is ==> $#"
echo "Your whole parameter is ==> '$@'"
shift # 迚行第一次『一个发量的 shift 』
echo "Total parameter number is ==> $#"
echo "Your whole parameter is ==> '$@'"
shift 3 # 迚行第二次『三个发量的 shift 』
echo "Total parameter number is ==> $#"
echo "Your whole parameter is ==> '$@'"
#!/bin/bashecho "hello world!"exit 0#!/bin/bashread -p "Please input your first name:" firstnameread -p "Please input your last name:" lastnameecho "Your full name is:$firstname $lastname"#!/bin/bashecho "I will use touch command to create 3