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.

2
  • Are you sure keeping a list of file names in memory can be a bigger problem than sorting such a big file? Commented Oct 12, 2022 at 6:03
  • @Philippos yes because sort is designed to efficiently handle massive amounts of input by using demand paging, etc. while awk when used as awk -F'/' '!seen[$NF]++' file will slow down greatly as the hash array size increases (it's allocated in increasingly larger blocks) before eventually failing when it runs out of memory. Commented Oct 12, 2022 at 13:08