mkdevlist 700 B

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