I have a folder of numbered data files. I am trying to incrementally extract a predefined range of files. The range of files that I am looking for is predefined in two variables, ns and ne, which change as the code runs.I have been attempting something like the following:$ ns=0001$ ne=0030$ ls foo_{$ns..$ne}.ncBut this does not read {$ns..$ne} as a sequence, and returns the error:ls: cannot access foo_{0001..0030}.nc: No such file or directoryIf I type the same command, but with the numbers entered manually, I get a list of files with numbers ranging from 0001 to 0030 as expected.I presume that I am making a fundamental error in the use of sequencing, but would appreciate someone informing me what this error is.Many thanks.
Listing numbered files using wildcard sequence with predefined range
bash;ls;filenames;wildcards;seq
Brace expansion happens before variable expansion, so there's no way to use variables in it. You can use seq instead:seq -f foo_%03.0f.nc $ns $ne