Python script
#!/usr/bin/env python
from __future__ import print_function
import sys
def get_order_package(filename):
order=None
package=None
with open(filename) as f:
for line in f:
if line.startswith('Order:'):
order=int(line.strip().split()[1])
if line.startswith('Package:'):
package=line.strip().replace("Package: ",'')
return (order,package)
order_list=[]
for argument in sys.argv[1:]:
order_list.append(get_order_package(argument))
order_list.sort(key=lambda x: x[0])
for i in order_list:
print('Order:',i[0])
print('Package:',i[1])
This script defines get_order_package() function which parses the file, and returns tuple in format (integer,package_string). We pass all files as command-line arguments and iterate over them, executing the function explained above for each one. That builds up a list, we sort it, and iterate again, printing each respective tuple parts from the new sorted list.
Test run
$ cat example_1.conf
Order: 0
Package: example_1
$ cat example_2.conf
Order: 2
Package: example_2
$ cat example_3.conf
Order: 1
Package: example_3
$ ./parse_conf.py *.conf
Order: 0
Package: example_1
Order: 1
Package: example_3
Order: 2
Package: example_2