Skip to main content
1 of 2

This works too:

grep -e ^Order -e ^Package `grep ^Order *.conf | awk -F: '{printf("%s:%s\n",$NF,$0);}' |sort| awk -F: '{print $2}'` 

Explanation (below multi-line format is only for demonstration, it does not work in bash):

$ grep -e ^Order -e ^Package ` \ # grep for lines starting with "Order" or "Package"; start nested command > grep ^Order *.conf | \ # grep for lines starting with "Order" in files *.conf > awk -F: '{printf("%s:%s\n",$NF,$0);}' | \ # prefixing order number with a separating colon > sort | \ # sort by order number > awk -F: '{print $2}' \ # extract file name alone ; now filenames are ordered by the order number contained within them > ` # end nested command