简体   繁体   English

如何使用 shell 脚本遍历多个文件?

[英]How do I loop through multiple files using shell script?

I have multiple files whose format of filename like: qs_l2b_yearday.nc ;我有多个文件,其文件名格式为: qs_l2b_yearday.nc for example: 1s_l2b_2008031.nc .例如: 1s_l2b_2008031.nc

I'm trying to use shell script to download these files from remote server, but unfortunately I cannot find a way to do that.我正在尝试使用 shell 脚本从远程服务器下载这些文件,但不幸的是我找不到这样做的方法。 With my limited understanding the code should loop through years as outside loop and loop through days as inside loop.以我有限的理解,代码应该循环数年作为外循环,循环数天作为内循环。 And the core code should use scp to download the file from server.核心代码应该使用 scp 从服务器下载文件。 I have figured out how to download one of those files using scp, but need some help to solve the "for loop" problem.我已经想出了如何使用 scp 下载这些文件之一,但需要一些帮助来解决“for 循环”问题。

Year is from 1999 to 2009. Day is from 001 to 365年份是从 1999 年到 2009 年。日是从 001 到 365

您可以像这样使用通配符来 scp 多个文件

scp user@somehost:/some/path/to/files/qs_l2b_*.nc /some/target/directory/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM