Linux第2部分中的还原脚本
在我的另一个问题中,我的剧本有问题;虽然我现在有第一部分工作。我对Linux和脚本也很陌生 如果我执行Linux第2部分中的还原脚本,linux,bash,shell,Linux,Bash,Shell,在我的另一个问题中,我的剧本有问题;虽然我现在有第一部分工作。我对Linux和脚本也很陌生 如果我执行restore-n 因此,如果我这样做: restore-n test1.txt 它会把问题还给我 “您想将文件保存在哪里?” 我再举个例子 /root这会将文件还原为root 如果我执行restore操作,则应将文件还原到原始位置。 因此,如果我这样做: restore test1.txt 它应该将它还原回/root/michael,但是当我尝试还原test1.txt时,我得到了错误 mv:
restore-n
因此,如果我这样做:
restore-n test1.txt
它会把问题还给我
“您想将文件保存在哪里?”
我再举个例子
/root
这会将文件还原为root
如果我执行restore
操作,则应将文件还原到原始位置。
因此,如果我这样做:
restore 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`