他の質問では、スクリプトに問題がありました。私は今、最初の部分が機能していますが。Linuxとスクリプティングも初めてです。
スクリプトは、ファイルを復元する場所を尋ねる必要があります。restore -n
だから私がそうするなら:
restore -n test1.txt
それは私に質問を返します
"Where would you like to save the file?"
次に、たとえば
/root
、ファイルをルートに復元します。
私がそうrestore
するならば、それはファイルを元の場所に復元するべきです。だから私がそうするなら:
restore test1.txt
に復元する必要/root/michael
がありますが、test1.txtを復元しようとすると、エラーが発生します
mv: missing file operand
これが私のスクリプトのこれまでの部分です。最初の部分は正常に機能していますが、2番目の部分で問題が発生しています。
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