- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我在远程服务器上有一个需要清除的文件夹。我需要删除此文件夹中的所有文件和文件夹。我无法删除和重新创建父文件夹,因为我不想弄乱权限。
例如:
远程文件夹是 Development/
该文件夹包含多个文件和多个文件夹。
我想运行一个命令来完全清空 Development/文件夹并给我一个新的空版本。
我还需要它与 Windows FTP 客户端兼容。
最佳答案
由于您澄清您不限于 ncftp,您应该使用 lftp相反,它内置了对使用 glob
之类的操作的支持。和 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] files
Remove remote files. Does not expand wildcards, use mrm for that. -r is for recursive directory remove. Be careful, if something goes wrong you can lose files. -f suppress error messages.
glob [-d] [-a] [-f] command patterns
Glob given patterns containing metacharacters and pass result to given command. E.g.
glob echo *
-f plain files (default)
-d directories
-a all types
mrm
在这种情况下不可用,因为它不会扩展
*
以包含目录。)
关于ftp - 使用ncftp删除文件夹中所有文件和文件夹的命令,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11692928/
我正在尝试创建一个将本地目录树上传到远程服务器的 shell 脚本。这部分代码工作正常。但是,当我添加 chmod 命令时,我得到了 ncftp> shell。 有人能帮帮我吗?这是我的代码:
在ncftp 选项卡补全中只显示匹配文件的差异。例如。使用以下文件 file123 file125 aa 然后键入 ls fil 将首先完成 ls file12 并显示 3 5 问题 可以在 Bash
我目前正在使用来自 cyberciti 的这个脚本 #!/bin/sh # System + MySQL backup script # Full backup day - Sun (rest of
我是一名优秀的程序员,十分优秀!