![如何按照时间戳列出?](https://linux22.com/image/202142/%E5%A6%82%E4%BD%95%E6%8C%89%E7%85%A7%E6%97%B6%E9%97%B4%E6%88%B3%E5%88%97%E5%87%BA%EF%BC%9F.png)
我有一组文件,如下所示。我每天有 4 个时间步长的数据。我想根据日期和时间列出这些NetCDF
文件,并使用cdo
.
anal_06z20210323.nc
anal_06z20210324.nc
anal_06z20210325.nc
anal_06z20210326.nc
anal_06z20210327.nc
anal_06z20210328.nc
anal_06z20210329.nc
anal_06z20210330.nc
anal_06z20210331.nc
anal_06z20210401.nc
anal_06z20210402.nc
anal_06z20210403.nc
anal_06z20210404.nc
anal_06z20210405.nc
anal_06z20210406.nc
anal_06z20210407.nc
anal_06z20210408.nc
anal_06z20210409.nc
anal_06z20210410.nc
anal_12z20210723.nc
anal_12z20210724.nc
anal_12z20210725.nc
anal_12z20210726.nc
anal_12z20210727.nc
anal_12z20210728.nc
anal_12z20210729.nc
anal_12z20210730.nc
anal_12z20210731.nc
anal_12z20210801.nc
anal_12z20210802.nc
anal_12z20210803.nc
anal_12z20210804.nc
anal_12z20210805.nc
anal_12z20210806.nc
anal_12z20210807.nc
anal_12z20210808.nc
anal_12z20210809.nc
anal_12z20210810.nc
anal_18z20211122.nc
anal_18z20211123.nc
anal_18z20211124.nc
anal_18z20211125.nc
anal_18z20211126.nc
anal_18z20211127.nc
anal_18z20211128.nc
anal_18z20211129.nc
anal_18z20211130.nc
anal_18z20211201.nc
anal_18z20211202.nc
anal_18z20211203.nc
anal_18z20211204.nc
anal_18z20211205.nc
anal_18z20211206.nc
anal_18z20211207.nc
anal_18z20211208.nc
anal_18z20211209.nc
anal_18z20211210.nc
答案1
我建议这样:
$ find . -name "*.nc" | \
xargs -I '{}' echo '{}' | \
sed -e 's/z/@/' -e 's/\./@/2' | \
sort -t@ -k2,2 | \
sed -e 's/@/z/' -e 's/@/./'
./anal_06z20210323.nc
./anal_06z20210324.nc
./anal_06z20210325.nc
./anal_06z20210326.nc
./anal_06z20210327.nc
./anal_06z20210328.nc
./anal_06z20210329.nc
./anal_06z20210330.nc
./anal_06z20210331.nc
./anal_06z20210401.nc
./anal_06z20210402.nc
./anal_06z20210403.nc
./anal_06z20210404.nc
./anal_06z20210405.nc
./anal_06z20210406.nc
./anal_06z20210407.nc
./anal_06z20210408.nc
./anal_06z20210409.nc
./anal_06z20210410.nc
./anal_12z20210723.nc
./anal_12z20210724.nc
./anal_12z20210725.nc
./anal_12z20210726.nc
./anal_12z20210727.nc
./anal_12z20210728.nc
./anal_12z20210729.nc
./anal_12z20210730.nc
./anal_12z20210731.nc
./anal_12z20210801.nc
./anal_12z20210802.nc
./anal_12z20210803.nc
./anal_12z20210804.nc
./anal_12z20210805.nc
./anal_12z20210806.nc
./anal_12z20210807.nc
./anal_12z20210808.nc
./anal_12z20210809.nc
./anal_12z20210810.nc
./anal_18z20211122.nc
./anal_18z20211123.nc
./anal_18z20211124.nc
./anal_18z20211125.nc
./anal_18z20211126.nc
./anal_18z20211127.nc
./anal_18z20211128.nc
./anal_18z20211129.nc
./anal_18z20211130.nc
./anal_18z20211201.nc
./anal_18z20211202.nc
./anal_18z20211203.nc
./anal_18z20211204.nc
./anal_18z20211205.nc
./anal_18z20211206.nc
./anal_18z20211207.nc
./anal_18z20211208.nc
./anal_18z20211209.nc
./anal_18z20211210.nc