如何使用shell脚本循环多个文件?

时间:2021-11-27 01:13:26

I have multiple files whose format of filename like: qs_l2b_yearday.nc; for example: 1s_l2b_2008031.nc.

我有多个文件的文件名格式如:qs_l2b_year .nc;例如:1 s_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. 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. I have figured out how to download one of those files using scp, but need some help to solve the "for loop" problem.

我尝试使用shell脚本从远程服务器下载这些文件,但不幸的是,我找不到一种方法。在我有限的理解下,代码应该以外部循环的形式循环多年,以内部循环的形式循环数天。核心代码应该使用scp从服务器下载文件。我已经知道如何使用scp下载其中一个文件,但是需要一些帮助来解决“for循环”问题。

Year is from 1999 to 2009. Day is from 001 to 365

年份是从1999年到2009年。一天从001到365天

1 个解决方案

#1


0  

You can use a wildcard to scp multiple files like so

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

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

#1


0  

You can use a wildcard to scp multiple files like so

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

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