LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 734|回复: 0

simple shell script question

[复制链接]
发表于 2006-10-25 23:53:15 | 显示全部楼层 |阅读模式
#!/bin/bash
# Program:
#         User can keyin filename to touch 3 new files.
# History:
# 2005/08/23        VBird        First release
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
export PATH

# 1. 讓使用者輸入檔案名稱,並取得 fileuser 這個變數;
echo -e "I will use 'touch' command to create 3 files."
read -p "lease input the filename what you want: " fileuser

# 2. 為了避免使用者隨意按 Enter ,利用變數功能分析檔名是否有設定?
filename=${fileuser:-"filename"}
########## I don't understand it.
########## BTW: My fcitx doesn't work.

# 3. 開始利用 date 指令來取得所需要的檔名了;
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"

# 4. 將檔名建立吧!
touch $file1
touch $file2
touch $file3
您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表