Pulse Pulse - 3 months ago 6x
Bash Question

Copy and pasted file names from finder on mac and vim showing ^M after each filename, how to fix?

I copy and pasted files from finder, into a text file to get the names of the files in a certain directory to a text file. When I open the file the files from each directory are all the same line...
For example: I copy and pasted from the "Hats Directory":
Line1 is:


In that same text file I copy and pasted files from the "Shoes" directory
Line 2 is:


I have tried


Neither of them work, am I going about this process the wrong one? Is there a more efficient way to do what I'm trying to do?


A more simple way is using bash truncate tr command.

Just do, tr -d '\r' < inputFile > outputFile to remove all the carriage return characters.