Linux Mastering Development

bash script to apply ncrcat on multiple files based on cycle number

I have a simulation model where I can run a simulation in multiple parts, where for each part output is generated with an increasing cycle number. Output files may look like the following:

To concatenate these files, I use nco, more specifically the record concatenator ncrcat. I used to do this manually like the following for each file name (a through c):

ncrcat a.00{0..2}.nc 

How would I go about writing a bash script that performs the ncrcat command on all files and concatenates all files with increasing cycle number (so, and to; next file would be,, to I got as far with egrep, etc. to extract which cycle numbers are present in an ls output, but do not know how to extract the file name.


Leave a Reply

Your email address will not be published. Required fields are marked *