Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个循环通过主机的脚本,通过 ssh 进入它们并执行一些任务。我还不能编写脚本的其中一项任务是将每个主机的文件 cp 到运行脚本的主机。它应该每天只 cp 一个文件,该文件每次都将位于同一位置,并且由不同脚本生成的文件名将前一天的日期合并到文件名中。例如,昨天的文件是 test_2021-03-10.txt。鉴于文件名将始终以该格式包含昨天的日期,我将如何编写脚本来查找该文件?谢谢。
也许是这样的?scp user@host:/path/to/file/test_$(date --date=yesterday +%Y_%m_%d).txt /path/to/archive/ 带有 GNU 日期。– M.内贾特·艾登