I'm trying to make a oneliner to be able to list all locked (forbidden to upgrade) packages in FreeBSD.Normally, you issue this command:pkg info -akIt outputs list of all packages in system including locked and unlocked which isn't working for me as I only want locked ones. If I grep 'yes' it does exactly what I want:pkg info -ak | grep yesIt outputs following:nginx-devel-1.5.10             yesphp5-extensions-1.7            yesphp55-5.5.8                    yesNow, what I want is to be able to edit that output a little bit by changing string 'yes' for following (adding package name w/ version omitted):nginx-devel-1.5.10             locked, run: sudo pkg unlock nginx-develphp5-extensions-1.7            locked, run: sudo pkg unlock php5-extensionsphp55-5.5.8                    locked, run: sudo pkg unlock php55I tried following unsuccessfully (newb here):pkg info -ak | grep yes | sed s/yes/locked - run: sudo pkg unlock $(pkg info -ak | grep yes | cut -d - f1-2)/While what I've tried isn't working I posted it just for you to get the idea what I'm trying to achieve.
Shell script to list locked packages in FreeBSD
bash;shell script;sed;freebsd
pkg info -ak | grep -w yes | while read line; do packnum=`echo $line | awk '{print $1}'`; pack=`echo $packnum | awk 'BEGIN{FS=OFS=-}{$NF=; NF--; print}'` ; printf %-33s%s\n $packnum locked, run: sudo pkg unlock$pack ;doneI added -w option to your grep to avoid confusion with packages containing yes in their name string.