助けが必要です。これは、dustbin ディレクトリから元の場所にファイルを復元するために使用するスクリプトです。以前はルートにありました。次に、他のスクリプトを使用して「削除」され、dustbin ディレクトリに保存され、以前の場所はこれを使用してストレージ ファイルに記録されました。
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: `filename' を stat できません: そのようなファイルまたはディレクトリはありません