2

I would like to perform command substitution before brace expansion, but couldn't:

$ ls {$(seq -s , 13 20)}.pdf
ls: cannot access {13,14,15,16,17,18,19,20}.pdf: No such file or directory

How can I do it?

5

You simply need to use the eval shell builtin:

$ eval ls {$(seq -s , 13 20)}.pdf

Where eval takes the arguments passed to it:

ls {$(seq -s , 13 20)}.pdf

and concatenates them together into a single command:

ls {13,14,15,16,17,18,19,20}.pdf

which is then read and executed by the shell.

$ eval ls {$(seq -s , 13 20)}.pdf
13.pdf  14.pdf  15.pdf  16.pdf  17.pdf  18.pdf  19.pdf  20.pdf
2

have you tried

ls $(seq -f %.0f.pdf 13 20 )
  • -f gives the format string
  • .0f for 0 decimal digit float
  • .pdf obvious

(and you know about $( ) syntax)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.