System Management

The file dos.txt has DOS-style CR+LF line endings. Which command writes a copy named unix.txt with Unix-style line endings?

Show the answer

Correct answerA. tr -d '\r' < dos.txt > unix.txt

AWhy this is right: Deleting every carriage return leaves the LF that ends each Unix line.

BWhy not this: Deleting \n removes the line feeds, joining the file into one line that still holds CRs.

CWhy not this: Turning each CR into LF gives two line feeds per line, so a blank line follows each one.

DWhy not this: tr takes no file name argument, and -s only squeezes repeats instead of removing CRs.

DOS files end lines with CR+LF. tr -d deletes the listed characters, so removing \r leaves only the LF that Unix tools expect. tr reads only standard input, which is why the file is redirected with <.