Which of the following commands will change all CR-LF pairs in an imported text file…

Which of the following commands will change all CR-LF pairs in an imported text file, userlist.txt, to Linux standard LF characters and store it as newlist.txt?

Which of the following commands will change all CR-LF pairs in an imported text file, userlist.txt, to Linux standard LF characters and store it as newlist.txt?

A.
tr ‘rn’ ” < userlist.txt > newlist.txt

B.
tr -c ‘nr’ ” < newlist.txt > userlist.txt

C.
tr -d ‘r’ < userlist.txt > newlist.txt

D.
tr ‘r’ ‘n’ userlist.txt newlist.txt

E.
tr -s ‘^M’ ‘^J’ userlist.txt newlist.txt

Explanation:
To change CR-LF (“rn”, DOS newline) to LF (“n”, Linux newline) just delete the CR “r” part from the file. This is done by using tr with the -d (delete) option.



Leave a Reply 2

Your email address will not be published. Required fields are marked *


Gray

Gray

Should it be tr -d ‘\r’ ?