"mv"コマンドを使用してファイルを失いましたが、ファイルがどこにあるのかわかりません!

このコマンドを使用してmv一部のファイルが失われました。私は彼らがどこにいるのかわかりません。コピーしたいディレクトリにありません。

私が書いた記録は次のとおりです。

samuelcayo@CAYS07019906:~/Downloads/221-tp2-public-main$ cd
samuelcayo@CAYS07019906:~$ ls
Desktop  Documents  Downloads  GameShell  Music  Pictures  pratice  Public  Templates  Videos
samuelcayo@CAYS07019906:~$ mkdir tp2
samuelcayo@CAYS07019906:~$ ls
Desktop  Documents  Downloads  GameShell  Music  Pictures  pratice  Public  Templates  tp2  Videos
samuelcayo@CAYS07019906:~$ cd Downloads/221-tp2-public-main/
samuelcayo@CAYS07019906:~/Downloads/221-tp2-public-main$ ls
backup  copybash  Dockerfile               ntfy-1.16.0  packets.txt     README.md      restore        secret
cloud   data      Dockerfile_CAYS07019906  ntfy.zip     rapport-tp2.md  remplacer.sed  sauvegarde.sh  tail
samuelcayo@CAYS07019906:~/Downloads/221-tp2-public-main$ mv rapport-tp2.md tp2
samuelcayo@CAYS07019906:~/Downloads/221-tp2-public-main$ mv Dockerfile_CAYS07019906 tp2
samuelcayo@CAYS07019906:~/Downloads/221-tp2-public-main$ mv packets.txt tp2
samuelcayo@CAYS07019906:~/Downloads/221-tp2-public-main$ mv sauvegarde.sh tp2
samuelcayo@CAYS07019906:~/Downloads/221-tp2-public-main$ cd
samuelcayo@CAYS07019906:~$ cd tp2/
samuelcayo@CAYS07019906:~/tp2$ ls
samuelcayo@CAYS07019906:~/tp2$ ls -l
total 0
samuelcayo@CAYS07019906:~/tp2$ cd ..

ベストアンサー1

ホームディレクトリにというディレクトリを作成しますtp2。つまり、ディレクトリを作成します~/tp2。次に、に変更し~/Downloads/221-tp2-public-mainて使用を開始しますmv

mv各ジョブの宛先をとして指定tp2し、tp2現在のディレクトリのディレクトリではないため、移動するすべてのファイルは名前変更 tp2。後で実行するたびに、以前にtp2呼び出されたファイルが上書きされますmv。結局tp2残っているのは以前に呼び出されたものですsauvegarde.sh

~/tp2/これをすべてのタスクのターゲットとして使用すると、データの損失を防ぐことができますmv

ディレクトリ~を作成したホームディレクトリを示します。tp2ターゲットパスの終わりには必ずしも/必要ではありませんが、mvディレクトリでない場合は正常に失敗します。~/tp2

失われたファイルを回復するために今できることについては、他の場所にコピーがない場合は、最近のバックアップから復元することを検討してください。

おすすめ記事