I have flyway migration scripts, which are named as follows.
V1__description.sql
V2.001__description.sql
V2.002__description.sql
V2__description.sql
The above is the order which they are listed by ls, or the default sort order of find. The order in which they are executed by flyway are
V1__description.sql
V2__description.sql
V2.001__description.sql
V2.002__description.sql
Is there a way to use the bash sort command to list the files in the order in which flyway executes them? The files cannot be renamed.
The answer to your question is "No. At least, not by itself."
First off, there is no "bash sort command". The
sort
command is not actually part of bash, it's a separate tool provided by your operating system. While its usage varies by operating system, no version that I'm aware of would sort your input the way you're asking for.[1] Find out more about its capabilities by runningman sort
in your shell.One option might be to stream your file list through something that makes it sortable, then stream it through the reverse conversion after sort:
[1] I'd love to be corrected on this point.