Skip to main content
added 14 characters in body
Source Link
Stéphane Chazelas
  • 584.8k
  • 96
  • 1.1k
  • 1.7k

i have a folder full of nc files from 1979 to 2018 daily data. i wish to combine it all to one nc but when i tried to list the files to create a ferret script, the order was changed.i am giving below a sample of the names of my data files. ERA5_2018_9_12_UVP.nc ERA5_2018_9_13_UVP.nc ERA5_2018_9_14_UVP.nc ERA5_2018_9_15_UVP.nc ERA5_2018_9_16_UVP.nc ERA5_2018_9_17_UVP.nc ERA5_2018_9_18_UVP.nc ERA5_2018_9_19_UVP.nc ERA5_2018_9_1_UVP.nc ERA5_2018_9_20_UVP.nc ERA5_2018_9_21_UVP.nc ERA5_2018_9_22_UVP.nc ERA5_2018_9_23_UVP.nc ERA5_2018_9_24_UVP.nc the

ERA5_2018_9_12_UVP.nc
ERA5_2018_9_13_UVP.nc
ERA5_2018_9_14_UVP.nc
ERA5_2018_9_15_UVP.nc
ERA5_2018_9_16_UVP.nc
ERA5_2018_9_17_UVP.nc
ERA5_2018_9_18_UVP.nc
ERA5_2018_9_19_UVP.nc
ERA5_2018_9_1_UVP.nc
ERA5_2018_9_20_UVP.nc
ERA5_2018_9_21_UVP.nc
ERA5_2018_9_22_UVP.nc
ERA5_2018_9_23_UVP.nc
ERA5_2018_9_24_UVP.nc

the dates are changing when i list them i tried a code in shell script to change the name of the files using sed command.

    for i in {1..9..1}
    do
    sed "s/_${i}_UVP/_0${i}_/g"
    done < temp```
can anyone help me in this regard?
ls *.nc >temp
    for i in {1..9..1}
    do
    sed "s/_${i}_UVP/_0${i}_/g"
    done < temp

can anyone help me in this regard?

i have a folder full of nc files from 1979 to 2018 daily data. i wish to combine it all to one nc but when i tried to list the files to create a ferret script, the order was changed.i am giving below a sample of the names of my data files. ERA5_2018_9_12_UVP.nc ERA5_2018_9_13_UVP.nc ERA5_2018_9_14_UVP.nc ERA5_2018_9_15_UVP.nc ERA5_2018_9_16_UVP.nc ERA5_2018_9_17_UVP.nc ERA5_2018_9_18_UVP.nc ERA5_2018_9_19_UVP.nc ERA5_2018_9_1_UVP.nc ERA5_2018_9_20_UVP.nc ERA5_2018_9_21_UVP.nc ERA5_2018_9_22_UVP.nc ERA5_2018_9_23_UVP.nc ERA5_2018_9_24_UVP.nc the dates are changing when i list them i tried a code in shell script to change the name of the files using sed command.

    for i in {1..9..1}
    do
    sed "s/_${i}_UVP/_0${i}_/g"
    done < temp```
can anyone help me in this regard?

i have a folder full of nc files from 1979 to 2018 daily data. i wish to combine it all to one nc but when i tried to list the files to create a ferret script, the order was changed.i am giving below a sample of the names of my data files.

ERA5_2018_9_12_UVP.nc
ERA5_2018_9_13_UVP.nc
ERA5_2018_9_14_UVP.nc
ERA5_2018_9_15_UVP.nc
ERA5_2018_9_16_UVP.nc
ERA5_2018_9_17_UVP.nc
ERA5_2018_9_18_UVP.nc
ERA5_2018_9_19_UVP.nc
ERA5_2018_9_1_UVP.nc
ERA5_2018_9_20_UVP.nc
ERA5_2018_9_21_UVP.nc
ERA5_2018_9_22_UVP.nc
ERA5_2018_9_23_UVP.nc
ERA5_2018_9_24_UVP.nc

the dates are changing when i list them i tried a code in shell script to change the name of the files using sed command.

ls *.nc >temp
    for i in {1..9..1}
    do
    sed "s/_${i}_UVP/_0${i}_/g"
    done < temp

can anyone help me in this regard?

Source Link

how to list without changing order in shell script?

i have a folder full of nc files from 1979 to 2018 daily data. i wish to combine it all to one nc but when i tried to list the files to create a ferret script, the order was changed.i am giving below a sample of the names of my data files. ERA5_2018_9_12_UVP.nc ERA5_2018_9_13_UVP.nc ERA5_2018_9_14_UVP.nc ERA5_2018_9_15_UVP.nc ERA5_2018_9_16_UVP.nc ERA5_2018_9_17_UVP.nc ERA5_2018_9_18_UVP.nc ERA5_2018_9_19_UVP.nc ERA5_2018_9_1_UVP.nc ERA5_2018_9_20_UVP.nc ERA5_2018_9_21_UVP.nc ERA5_2018_9_22_UVP.nc ERA5_2018_9_23_UVP.nc ERA5_2018_9_24_UVP.nc the dates are changing when i list them i tried a code in shell script to change the name of the files using sed command.

    for i in {1..9..1}
    do
    sed "s/_${i}_UVP/_0${i}_/g"
    done < temp```
can anyone help me in this regard?