ncftp に限定されないことを明確にしたので、代わりにlftpglob
を使用する必要がありrm -r
ます。完全なデモンストレーションを次に示します。
~/ftptest$ find . # Test folder with a number of files and directories in it.
.
./dir1
./dir1/subdir1
./dir1/subdir1/subsubfile1
./dir1/subfile1
./dir2
./file1
./file2
~/ftptest$ lftp localhost # Connect
Password:
lftp blahdiblah@localhost:~> cd ~/ftptest/ # cd to test folder
cd ok, cwd=/Users/blahdiblah/ftptest
lftp blahdiblah@localhost:~ftptest> ls # The files are there...
total 0
drwxr-xr-x 4 blahdiblah staff 136 Jul 30 15:40 dir1
drwxr-xr-x 2 blahdiblah staff 68 Jul 30 15:40 dir2
-rw-r--r-- 1 blahdiblah staff 0 Jul 30 15:40 file1
-rw-r--r-- 1 blahdiblah staff 0 Jul 30 15:40 file2
lftp blahdiblah@localhost:~/ftptest> glob -a rm -r * # the magic happens...
rm ok, 7 files removed
lftp blahdiblah@localhost:~/ftptest> bye
~/ftptest$ find . # ...and then they're gone!
.
~/ftptest$
ドキュメントは完全な説明を提供します:
rm [ -r ] [ -f ]ファイル
リモート ファイルを削除します。ワイルドカードを展開しないため、mrmを使用します。-r は、再帰的なディレクトリ削除用です。何か問題が発生すると、ファイルが失われる可能性があるので注意してください。-f エラー メッセージを抑制します。
glob [ -d ] [ -a ] [ -f ]コマンドパターン
メタ文字を含む特定のパターンをグロブし、結果を特定のコマンドに渡します。例えば
glob echo *
-f プレーン ファイル (デフォルト)
-d ディレクトリ
-a すべてのタイプ
(ディレクトリを含むようにmrm
展開されないため、この場合は使用できないことに注意してください。)*