我是shell腳本編程新手,我試圖自動化一個進程。 我認爲結構是好的,但我得到通知,我認爲它不應該存在Bash-shell腳本修改和建議
# STEP 1#
echo " Untar the file s"
time tar -xf $tarfiles
time tar -xf *.tar
#STEP 2#
fname=(wnd10m.gdas.2010*.grb2)
echo " convert into .nc "
cdo -f nc copy $fname $fname.nc
#STEP 3#
ofile1=$fname.nc
echo "re-format into structured grid 0.5x0.5"
cdo remapbil,r720x361 $ofile1 remap$R.nc
#STEP 4#
ofile2=$remapR.nc
echo "produce desired mesh"
cdo sellonlatbox,lon1,lon2,lat1,lat2 $ofile2 $grid.nc
#STEP 5#
ofile3=$grid.nc
echo "merge the files based on tstep"
cdo mergetime $ofile3 final$R.nc
步驟1和2,儘管它只是操縱進行,並改變它被列入該文件的一個.tar文件。
方法到目前爲止給出的步驟1 & 2,但在步驟3期間,我不其中R是這樣產生的不與在先前步驟中產生的其它混淆的附加結束得到新的文件作爲remap$R.nc
。
後,我運行它,這是我所得到的
convert into .nc
cdo copy: Processed 987365376 values from 2 variables over 744 timesteps (234.66s)
re-format into structured grid 0.5x0.5
cdo remapbil: Processed 987365376 values from 2 variables over 744 timesteps (53.59s)
produce desired mesh
Error (cdo sellonlatbox) : Output file name .nc is equal to input file name on position 1!
merge the files based on tstep
cdo mergetime: Open failed on >.nc<
No such file or directory
我試圖去想跟我的文件,但不知道我做錯了,因爲這個過程應該處理很多文件將其轉換爲每個階段,我非常重視分配正確的和不同的fnames
。
如果你能看一看,並給我你的意見,我將不勝感激。
p.s. CDO是我使用的,所以你可以忽略它的代碼,我的重點是過程本身
感謝
@Bushmils。我做了這種形式,以便在轉換中爲每個文件添加一個不同的結尾,然後將其用作下一組命令的輸入文件 儘管我認爲我弄糟了那部分,但我會改變它,跑。 – George
沒有改變,但結果是 CDO sellonlatbox:打開失敗上> .NC < 沒有這樣的文件或目錄 合併基於TSTEP CDO mergetime文件:打開失敗上> .NC < 沒有這樣的文件或目錄 – George
「做了這種形式,以便爲每個文件添加一個不同的結尾」我不明白。你沒有給變量R分配任何東西,因此其內容未定義,或者你沒有顯示你分配的內容。 –