Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

6
  • This looks really promissing! what does the line c | getline p do? Commented Aug 28, 2022 at 11:00
  • @N3buchadnezzar expanded on it a little. See also for example: stackoverflow.com/q/1960895/3342816 , unix.stackexchange.com/a/139559/140633 etc. Commented Aug 28, 2022 at 11:10
  • 2
    cmd = "realpath -m /proc/"$2"/exe" should be cmd = "realpath -m \047/proc/"$2"/exe\047" or the contents of $2 will be exposed to the shell for globbing, word splitting, and filename expansion. cmd | getline path should be if ( (cmd | getline path) > 0 ) { ... or similar to protect against failures in cmd | getline, see awk.freeshell.org/AllAboutGetline. Commented Aug 28, 2022 at 12:08
  • 2
    Regarding !x[$1]++ = an array used in that context is commonly, idiomatically named seen instead of x for clarity, i.e. !seen[$1]++. Changing a field as in $2 = path" "$2 will change all of the white space on the line to individual blank chars which may be undesirable. I know the OP is outputing to column -t but that will corrupt the output if a path contains spaces. print $0 can be written as just print since $0 is what is printed by default. Commented Aug 28, 2022 at 12:10
  • 1
    @EdMorton Thanks for the pointers. Commented Aug 30, 2022 at 5:46