【问题标题】:Skip duplicate lines when downloading text file from SFTP server with WinSCP使用 WinSCP 从 SFTP 服务器下载文本文件时跳过重复行
【发布时间】:2018-01-19 23:08:35
【问题描述】:

是否有命令让 WinSCP 批处理文件只将远程文件中的非重复值附加到本地文件?

这是我的批处理命令:

@echo off

"C:\Program Files (x86)\WinSCP\WinSCP.com" ^
  /log="C:\Users\U37615\Documents\POCLOSEBATCHLOG\WinSCP.log" /ini=nul ^
  /command ^
    "open xxxxxx -hostkey=""ssh-rsa 2048 xx:xx:xx:xx:xx:xx:xx....""" ^
    "get -append -delete xxxxxx"" ""xxxxxxx""" ^
    "exit"

set WINSCP_RESULT=%ERRORLEVEL%
if %WINSCP_RESULT% equ 0 (
  echo Success
) else (
  echo Error
)

pause
exit /b %WINSCP_RESULT%

我在远程服务器上有一个文本文件,我想追加到本地文件,但我只想追加本地列表中没有的项目。关于完成此任务的命令或解决方法有什么想法吗?

【问题讨论】:

    标签: batch-file sftp winscp


    【解决方案1】:

    绝对不是。这是一个自定义要求,您不能合理地期望任何 SFTP 客户端开箱即用地支持它。


    将远程文件(无-append)下载到临时本地文件(temp.txt)。

    然后执行以下操作:

    powershell -Command "type local.txt, temp.txt | sort -unique > combined.txt"
    

    一些参考资料:

    【讨论】:

      猜你喜欢
      • 2018-08-31
      • 2018-03-21
      • 1970-01-01
      • 2021-05-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多