需要幫助。這是我用來將文件從垃圾箱目錄恢復到其原始位置的腳本。它位於根之前。然後使用其他腳本,這是「被刪除」,並存儲在垃圾箱目錄,和它的前位置使用該存儲文件中記錄:使用腳本時,下面我要恢復被刪除的文件在linux bash腳本中恢復
case $ans in
y) echo "`readlink -f $1`" >>home/storage & mv $1 /home/dustbin ;;
n) echo "File not deleted." ;;
*) echo "Please input answer." ;;
esac
左右,但以下錯誤出現。
#!/bin/sh
if [ "$1" == "-n" ] ; then
cd ~/home/dustbin
restore="$(grep "$2" "$home/storage")"
filename="$(basename "$restore")"
echo "Where to save?"
read location
location1="$(readlink -f "$location")"
mv -i $filename "$location1"/$filename
else
cd ~/home
storage=$home/storage
restore="$(grep "$1" "$storage")"
filename="$(basename "$restore")"
mv -i $filename $restore
fi
給定的錯誤 - mv: missing file operand
編輯:
這麼好,我改變了我的腳本是這樣的。
#!/bin/sh
if [ $1 ] ; then
cd ~/home
storage=~/home/storage
restore="$(grep "$1" "$storage")"
filename="$(basename "$restore")"
mv -i "$filename" "$restore"
fi
,我仍然得到錯誤:
MV:不能STAT'文件名':沒有這樣的文件或目錄
在第二個'mv'行之前加上'echo'<$filename><$restore>''(與第一行相似),看看發生了什麼。 – choroba
可能重複[在Linux中恢復腳本](http://stackoverflow.com/questions/13615100/restore-script-in-linux) – shellter
請學習如何在StackOverflow中使用搜索功能。 '[bash]恢復文件'返回已經被回答的許多問題。祝你好運。 – shellter