I want to create a simple bash-script that checks whether a directory contains all the files whose names contain numbers from 1 to N.
# Creating some files for testing
$ cd /tmp/
$ mkdir test
$ touch test/a01x.dat
$ touch test/b02y.dat
# Display dir contents
$ ls test/*{01,02}*
test/a01x.dat test/b02y.dat
But using seq command to generate numbers results in the following:
$ ls test/*{$(seq -s , -f "%02g" 1 2)}*
ls: cannot access 'test/*{01,02}*': No such file or directory
I understand that running the command by surrounding the path with single quotation marks must lead to the error because the wildcards don't expand
$ ls 'test/*{01,02}*'
But I didn't use them. What is the problem?
ls test/*{01,02}*seems to indicate so...) ? Also, what format will the numbers be in? If N=100 will you use 001 or 1 or ?? to start?cannot accesserror message fromlsalways shows the name in question surrounded with quotes, that has nothing to do with your problem. It might depend on the version ofls, though. Try something likels foo "foo "