On Thu, Jun 27, 2019 at 05:39:14PM -0700, Dan Mahoney (Gushi) wrote: > Is there any good way that people would recommend parsing alias and map > files? The closest I've come would be counting the number of lines of > output to stderr, rather than looking at exit code, but that still seems > contrived.
One possible work-around is: ln -f foo foo.tmp postalias hash:foo.tmp gotkeys=$(postmap -s hash:foo.tmp | pcregrep -c '^[^\s#]') wanted=$( (cat foo.tmp; echo "@ @") | pcregrep -c '^[^\s#]' ) if [ "$gotkeys" -eq "$wanted" ]; then /bin/mv foo.tmp.db foo.db else # Error ... /bin/rm -f foo.tmp foo.tmp.db exit 1 fi -- Viktor.