Reconnaissance and Enumeration
A tester merges hostname lists from several tools into hosts.txt and needs each hostname listed only once. Which command does this?
Show the answer
Correct answerD. sort -u hosts.txt
AWhy not this: It extracts the first dot-delimited field of every line, which trims names and leaves duplicates in place.
BWhy not this: It only counts the lines in the file and neither removes duplicates nor outputs a hostname list.
CWhy not this: It prints only the first line of the file, discarding the rest of the list rather than deduplicating it.
DWhy this is right: It sorts the lines and keeps one copy of each, which deduplicates the merged list.
sort -u sorts the lines and drops duplicates, leaving one entry per hostname. wc -l only counts lines, so duplicates would remain and the output would be a number rather than a list.