Используйте ассоциативный массив для хранения имен сертификатов для каждой роли и среды.
#! /bin/bash
unset -v envs
declare -A envs
while IFS='| ' read -r certname role env; do
envs["$role.$env"]+="$certname"$'\n'
done < /tmp/inventory.list
for e in "${!envs[@]}" ; do
printf '%s\n' "[$e]" "${envs[$e]}"
done
Чтобы отсортировать разделы, вы можете распечатать ключи, отсортировать их, а затем прочитать их и вывести связанные значения:
for e in "${!envs[@]}" ; do
printf '%s\n' "$e"
done | sort | while read -r e ; do
printf '%s\n' "[$e]" "${envs[$e]}"
done
Несколько советов, которые помогут вам выбрать правильное направление:
ACL справочная страница в разделе говорится об ACL по умолчанию:
The access ACL of a file object is initialized when the object is created with any of the creat(), mkdir(), mknod(), mkfifo(), or open() functions. If a default ACL is associated with a directory, the mode parameter to the functions creating file objects and the default ACL of the directory are used to determine the ACL of the new object:
The new object inherits the default ACL of the containing directory as its access ACL.
The access ACL entries corresponding to the file permission bits are modified so that they contain no permissions that are not contained in the permissions specified by the mode parameter.
Используя sticky bit для каталогов, вы можете изменить владельца/группу новых файлов, созданных в каталоге. Файлы, созданные в каталоге, будут иметь владельца/группу закрепленного каталога вместо группы по умолчанию. Подробнее см. вопрос :. Как работает sticky bit?