シェルスクリプトを使用してhdf5ファイルのリストを同じ名前のnetcdfファイルに変換する

シェルスクリプトを使用してhdf5ファイルのリストを同じ名前のnetcdfファイルに変換する

次のように、毎月のフォルダごとに並べ替えられた衛星データを含むデータセットのリストがあります。

01  02  03  04  05  06  07  08  09  10  11  12

これらのフォルダは、毎日のデータフォルダに分けられます。たとえば、最初の月の場合、01日次ファイルは次のようにフォルダーにソートされます。

01  02  03  04  05  06  07  08  09  10  11  12  13  14  15  16  17  18  19  20  21  22  23  24  25  26  27  28  29  30  31

最後に、データセットがあります。

OMI-Aura_L2-PROFOZ_2016m0101t0059-o60970_v003-2016m0107t153711.he5.met  OMI-Aura_L2-PROFOZ_2016m0101t1410-o60978_v003-2016m0107t153715.he5
OMI-Aura_L2-PROFOZ_2016m0101t0237-o60971_v003-2016m0107t153714.he5      OMI-Aura_L2-PROFOZ_2016m0101t1410-o60978_v003-2016m0107t153715.he5.met
OMI-Aura_L2-PROFOZ_2016m0101t0237-o60971_v003-2016m0107t153714.he5.met  OMI-Aura_L2-PROFOZ_2016m0101t1549-o60979_v003-2016m0107t153713.he5
OMI-Aura_L2-PROFOZ_2016m0101t0416-o60972_v003-2016m0107t153715.he5      OMI-Aura_L2-PROFOZ_2016m0101t1549-o60979_v003-2016m0107t153713.he5.met
OMI-Aura_L2-PROFOZ_2016m0101t0416-o60972_v003-2016m0107t153715.he5.met  OMI-Aura_L2-PROFOZ_2016m0101t1727-o60980_v003-2016m0107t153718.he5
OMI-Aura_L2-PROFOZ_2016m0101t0555-o60973_v003-2016m0107t153709.he5      OMI-Aura_L2-PROFOZ_2016m0101t1727-o60980_v003-2016m0107t153718.he5.met
OMI-Aura_L2-PROFOZ_2016m0101t0555-o60973_v003-2016m0107t153709.he5.met  OMI-Aura_L2-PROFOZ_2016m0101t1906-o60981_v003-2016m0107t153716.he5
OMI-Aura_L2-PROFOZ_2016m0101t0734-o60974_v003-2016m0107t153717.he5      OMI-Aura_L2-PROFOZ_2016m0101t1906-o60981_v003-2016m0107t153716.he5.met
OMI-Aura_L2-PROFOZ_2016m0101t0734-o60974_v003-2016m0107t153717.he5.met  OMI-Aura_L2-PROFOZ_2016m0101t2045-o60982_v003-2016m0107t153719.he5
OMI-Aura_L2-PROFOZ_2016m0101t0913-o60975_v003-2016m0107t153711.he5      OMI-Aura_L2-PROFOZ_2016m0101t2045-o60982_v003-2016m0107t153719.he5.met
OMI-Aura_L2-PROFOZ_2016m0101t0913-o60975_v003-2016m0107t153711.he5.met  OMI-Aura_L2-PROFOZ_2016m0101t2224-o60983_v003-2016m0107t153717.he5

.he5拡張子を持つファイルを抽出し、ファイル名を保持する次のコードを使用してnetcdfファイルに変換したいと思います。

ncks inputfile.he5 inputfile.nc

各ファイルを処理しようとしてシェルスクリプトを作成しました。

shopt -s globstar
   for f in ./**; do
       echo "$f" |grep -v .met | grep ".he5"
       echo "$f" |grep -v .met |ncks $(grep".he5") $(echo $(grep  -o 'OMI-Aura_L2-PROFOZ_[0-9]\{4\}m[0-9]\{4\}t[0-9]\{4\}-o[0-9]\{5\}_v003-[0-9]\{4\}m[0-9]\{4\}t[0-9]\{6\}').nc)
   done
         

                                                                                                                                                                                           

ファイル名を抽出できますが、出力を取得できません。最終的にすべてのファイルをどのように変換できますか?

ベストアンサー1

コマンドが複雑すぎるため、同様のコマンドは必要ありませんgrep

shopt -s globstar
for f in ./**/*.he5; do
    ncks "$f" "${f%.*}.nc"
done
  • ${f%.*}最後の文字から始まるすべての文字を削除します。.

おすすめ記事