mkdevlist 510 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. #!/bin/rc
  2. awk '
  3. BEGIN{ collect = isdev = 0;
  4. }
  5. /^$/{ next;
  6. }
  7. /^#/{ next;
  8. }
  9. collect && /^[^ \t]/{
  10. collect = isdev = 0;
  11. }
  12. collect && $0 ~ /[^ \t]+/{
  13. if(isdev)
  14. obj["dev" $1 "'.$O'"]++;
  15. else
  16. obj[$1 "'.$O'"]++;
  17. for(i = 2; i <= NF; i++){
  18. if($i !~ "[+=-].*")
  19. obj[$i "'.$O'"]++;
  20. }
  21. }
  22. $0 ~ /^[^ \t]/{
  23. if($1 ~ "dev"){
  24. isdev = 1;
  25. collect = 1;
  26. }
  27. else if($1 ~ "misc" || $1 ~ "link" || $1 ~ "ip")
  28. collect = 1;
  29. next
  30. }
  31. END{
  32. x = ""
  33. for(i in obj)
  34. x = x i "\n"
  35. printf x
  36. }' $*