Somebody supplied me with a file that was edited on a Windows machine. The file contains carriage returns in addition to the newlines. I need to eliminate the carriage returns, so I use a. tr b. diff c. Onl d. cut
Computers and Technology · College · Tue Nov 03 2020
Answered on
To eliminate carriage returns from a file edited on a Windows machine, you can use the tr
command. The correct answer is:
a. tr
The tr
command (translate or delete characters) is commonly used for character-level transformations in Unix-like operating systems. In this case, you can use tr
to delete carriage returns (\r
) from the file. Here is an example:
bash Copy code tr -d '\r' < input_file > output_file
This command reads the contents of input_file
, deletes any carriage returns, and writes the result to output_file
. After running this command, the output file will have the carriage returns removed.
Options b, c, and d (diff
, Onl
, cut
) are not typically used for removing or replacing characters like carriage returns in the same way as tr
.