BASH   53

find level

Guest on 24th November 2022 03:20:09 PM

  1. #!/bin/sh
  2.  
  3. find_level() {
  4.   if [ "$1" = 1 ]; then
  5.     pkg_info | awk '{print $1}' | while read name
  6.     do
  7.       grep -q '^@pkgdep' /var/db/pkg/$name/+CONTENTS || echo $name
  8.     done > l1
  9.     return
  10.   fi
  11.  
  12.   cat l* > "s$1"
  13.   pkg_info | awk '{print $1}' | fgrep -xvf "s$1" | while read name
  14.   do
  15.     awk '/^@pkgdep/ {print $2}' /var/db/pkg/$name/+CONTENTS | grep -qxvf "s$1" || echo $name
  16.   done > "l$1"
  17. }
  18.  
  19. i=1
  20. find_level $i
  21. while [ -s "l$i" ]
  22. do
  23.   i=$(($i+1))
  24.   find_level $i
  25. done

Raw Paste


Login or Register to edit or fork this paste. It's free.