脚本文件名具有前导数字以确定执行顺序的用例

Tho*_*ggi 9 filesystem command-line bash scripts

我正在寻找文档或用例,其中在 Linux 中有一个包含 shell 脚本的目录,其中每个文件名都以一个数字开头,并且文件以该特定顺序运行。这个约定叫什么,在哪里使用?

例如:

0001-motd.sh
0002-proxy.sh
0300-ssh.sh
Run Code Online (Sandbox Code Playgroud)

我知道我以前见过这个,只是不知道它在哪里或叫什么。

ste*_*ver 12

听起来你指的是 run-parts

NAME
       run-parts - run scripts or programs in a directory

SYNOPSIS
       run-parts  [--test]  [--verbose] [--report] [--lsbsysinit] [--regex=RE]
       [--umask=umask] [--arg=argument] [--exit-on-error] [--help] [--version]
       [--list] [--reverse] [--] DIRECTORY

       run-parts -V

DESCRIPTION
       run-parts  runs  all  the  executable  files  named  within constraints
       described below, found in directory directory.  Other files and  direc?
       tories are silently ignored.

       If neither the --lsbsysinit option nor the --regex option is given then
       the names must consist entirely of ASCII upper- and lower-case letters,
       ASCII digits, ASCII underscores, and ASCII minus-hyphens.

       If  the  --lsbsysinit  option  is given, then the names must not end in
       .dpkg-old  or .dpkg-dist or .dpkg-new or .dpkg-tmp, and must belong  to
       one  or more of the following namespaces: the LANANA-assigned namespace
       (^[a-z0-9]+$);   the   LSB   hierarchical   and   reserved   namespaces
       (^_?([a-z0-9_.]+-)+[a-z0-9]+$);  and  the  Debian cron script namespace
       (^[a-zA-Z0-9_-]+$).

       If the --regex option  is  given,  the  names  must  match  the  custom
       extended regular expression specified as that option's argument.

       Files  are  run  in  the  lexical  sort order (according to the C/POSIX
       locale character collation rules) of their names unless  the  --reverse
       option is given, in which case they are run in the opposite order.
Run Code Online (Sandbox Code Playgroud)