rsp.awk (453B)
1 function line() { 2 if (match($0, /\.d$/)) 3 read($0) 4 else 5 libs[++n] = $0 6 } 7 8 function read(name) { 9 for (;;) { 10 ret = getline < name 11 if (ret < 0) { 12 print "failed to read line from " name > "/proc/self/fd/2" 13 exit(1) 14 } 15 if (ret == 0) 16 break 17 line() 18 } 19 close(name) 20 } 21 22 {line()} 23 24 END { 25 for (i = n; i > 0; --i) { 26 lib = libs[i] 27 if (lib in seen) 28 continue 29 seen[lib] = 1 30 uniq[++m] = lib 31 } 32 for (i = m; i > 0; --i) 33 print uniq[i] 34 }