在我的另一个问题中,我遇到了脚本问题;虽然我现在已经完成了第一部分。我对 Linux 和脚本编写也很陌生。
如果我执行 restore -n
所以如果我这样做:
恢复-n test1.txt
它会给我回复问题
“您想将文件保存在哪里?”
然后我会举个例子
/root
这会将文件恢复到根目录。
如果我执行恢复
,它应该将文件恢复到原始位置。
所以如果我这样做:
恢复test1.txt
它应该将其恢复到 /root/michael
,但是当我尝试恢复 test1.txt 时,出现错误
mv: missing file operand
这是到目前为止我的脚本,虽然第一部分工作正常,但我遇到了问题的第二部分
if [ "$1" == "-n" ]
then
cd /root/michael/trash
restore`grep "$2" /root/michael/store`
filename=`basename "$restore"`
echo "Where would you like to save the file?"
read location
location1=`readlink -f "$location"`
mv -i $filename "location1"/filename
else
location=`cd /root/michael`
cd /root/michael/trash
restore=`grep "$2" /root/michael/store`
filename=`basename "$restore"`
mv -i $filename "$location1" $location
fi
最佳答案
您错过了一项作业
restore`grep "$2" /root/michael/store`
关于linux - Linux 中的恢复脚本第 2 部分,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13624237/