标签:filename
[centos@lob1 scripts]$ vi sh03.sh
#! /bin/bash
#Program
# This program shows "Hello World!" in your screen.
#History
#2014/09/15 lobs Mon release
PATH=/bin:/sbin:/usr/bin:usr/sbin:/usr/local/bin:usr/local/sbin:~bin
export=PATH
echo -e"I will use ‘touch‘ command to create 3 files."
read -p"Please input your filename:" fileuser //注意空格,fileuser 之前有个空格
filename=${fileuser:-"filename"} // filename 变量未设定或为空,取“-”后面的值,
否则filename=$fileuser
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"
标签:filename
原文地址:http://itwastetime.blog.51cto.com/8955659/1552908