インポートされたテキストファイルuserlist.txtのすべてのCR-LFペアをLinux標準LF文字に変更し、newlist.txtとして保存するコマンドは次のうちどれですか?
正解:C
Explanation
The tr command is used to translate, squeeze, or delete characters from a file or a stream. The -d option is used to delete characters that appear in the first operand. The \r and \n are escape sequences that represent the carriage return and the line feed characters, respectively. The CR-LF pair is the standard line ending for Windows text files, while the LF character is the standard line ending for Linux text files. Therefore, the command tr -d '\r' < userlist.txt > newlist.txt will delete all the CR characters from the userlist.txt file and redirect the output to the newlist.txt file, effectively converting the line endings from Windows to Linux format. The other commands are incorrect because they either use the wrong syntax, the wrong operands, or the wrong redirection. References:
* LPI 101-500 Exam Objectives, Topic 103.7, Weight 4
* LPI Learning Materials, Chapter 3.7, Basic Scripting
* Web Search Results, 1