#!/usr/bin/env -S bash for line in $(home-manager generations | grep -o '/.*') do res=$(find $line | grep specialisation | head -1) output=$? if [[ $output -eq 0 ]] && [[ $res != "" ]]; then echo $res exit fi done