您的位置:首页 > 运维架构 > Shell

Linux基础09_shellscript练习

2016-04-10 18:06 633 查看
i sh02.sh

#!/bin/bash

#    User inputs his first name and last name.

#    Program shows his full name.

read -p “Please input yourfirst name:” firstname

read -p “Please input yourlast name:” lastname

echo –e “\n Your full nameis:$firstname$lastname”

 

 

 

vi sh03.sh

#!/bin/bash

让使用者输入文件名称,取得 fileuser 这个变量;

echo -e "I will use'touch' command to create 3 files."

 

# 提示使用者输入

read -p "Please inputyour filename:" fileuser        

 

#创建日期

filename=${fileuser:-"filename"}         

date1=$(date +%Y%m)

date2=$(date +%Y%m)

date3=$(date +%Y%m%d)                    

file1=${filename}${date1}”08”               file2=${filename}${date2}”09”

file3=${filename}${date3}

 

# 创建文件

touch "$file1"                            

touch "$file2"

touch "$file3

vi sh04.sh

#!/bin/bash

echo -e "input 2numbers, I cross them! \n"

read -p "first number: "firNum

read -p "second number:"secNum

total=$(($firNum *$secNum))

echo -e " result:$total"

注意:



内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  linux