CompTIA Linux+ (XK0-004) — Question 309

An administrator has a CSV file named hosts.csv. The contents of hosts.csv include the following:
192.168.2.57,lnx1prd.example.com,Linux,Production
192.168.2.58,lnx2prd.example.com,Linux,Production
192.168.1.4,server15.example.com,Windows,Development
The administrator needs to create a second comma-separated list of only the Linux server IP addresses. Which of the following commands would achieve this need?

Answer options

Correct answer: A

Explanation

The correct command (A) uses grep to filter lines containing 'Linux' and then cuts out the first field, which corresponds to the IP addresses. Option B incorrectly attempts to cut before grepping, which does not guarantee that only Linux servers are processed. Option C uses sed incorrectly, and option D does not properly format the command for the intended output, making them ineffective for this task.