【发布时间】:2016-01-21 18:28:19
【问题描述】:
我正在尝试编写一个 bash 脚本来询问数据/时间和文件名,然后更改输入文件的最后修改日期:
#!/bin/bash
clear
#set -x
echo "Please enter the new date/time stamp"
echo -n "in the form of [ YYYY MM DD hh mm ss ] [ENTER]:"
read YYYY MM DD hh mm ss
echo -n "Please enter the file name. [ENTER]:"
read FNAME
echo touch -d \"$YYYY"-"$MM"-"$DD" "$hh":"$mm":"$ss\" \"$FNAME\"
touch -d \"$YYYY"-"$MM"-"$DD" "$hh":"$mm":"$ss\" \"$FNAME\"
我收到一个令人困惑的错误:
touch: 无效的日期格式‘"2016-01-21 03:03:03"’
如果我从脚本中复制并粘贴我回显到屏幕的行:
touch -d "2016-01-21 03:03:03" "test.docx"
脚本完美运行。
一如既往,我们将不胜感激任何见解
【问题讨论】: