【问题标题】:How to not list "." and ".." in curl command : " curl -l ftp: "如何不列出“。”和 curl 命令中的“..”:“ curl -l ftp:”
【发布时间】:2019-10-03 06:52:56
【问题描述】:

命令:curl -l ftp://test:test@test/test/

任务:不列出“.”和“..

输出:

.
..
test.txt
test_2.txt

期望的输出:

test.txt
test_2.txt

【问题讨论】:

  • 要么更改您的 ftp 服务器端,要么只是 grep -v 输出中的这些行。

标签: bash shell curl ftp


【解决方案1】:

使用 GNU sed。我建议将此附加到您的命令中以删除仅包含一个或两个点的行:

| sed -r '/^\.{1,2}$/d'

并添加到 curl 选项 -s (silent) 以抑制其统计输出。


请参阅:man sedThe Stack Overflow Regular Expressions FAQ

【讨论】:

  • 您的代码有效,但这次curl% Total % Received % Xferd Average Speed Time Time Time Current 添加到列表顶部。它实际上更多,有3行。这是我测试您的代码的方式:test="ftp://test:test@test/test/" ... curl -l $test | sed -r '/^\.{1,2}$/d'
  • 我建议在 curl 中添加选项-s (silent)。
  • 添加“-s”标志有效。答案下关于s 标志的评论应被视为答案的一部分。我选择这个答案作为“选择的答案”。
猜你喜欢
  • 2021-03-31
  • 1970-01-01
  • 2016-04-22
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-04-18
  • 2015-11-05
  • 1970-01-01
相关资源
最近更新 更多