

For example, if you want to create a file called 'testfile,' type nano testfile and press Enter.

This creates and opens a new text file with that name. MacOS: tab2space - Expand tabs and ensure consistent cr/lf line endings. Replace filename with the name you want to give your new text file. StampMe - Rename a file with the current Date/Time. “Well, it's all right, if you live the life you please, Well, it's all right, even if the sun don't shine, Well, it's all right, we're going to the end of the line” ~ Traveling Wilburys, End Of The Line Get-Content $OldFile | Set-Content -Path $NewFile When these lines are written back into a new file, Set-Content will insert the default Windows CR/LF line endings. Get-Content will identify even non-standard line breaks, so the result is a string array of lines. replace but that will add a trailing CR/LF, so we use ::WriteAllText instead.Ī simple but less flexible method from, is below. The normal PowerShell routine to replace characters is. The script loads the whole file into memory so may not be suitable for very large files.
#Change mac text file to unix how to#
$text = ::ReadAllText($file) -replace "`n", $eolįor instructions of how to download and run this script see: Run a PowerShell script. # At this point all line-endings should be LF. $text = ::ReadAllText($file) -replace "`r", "`n"

# Convert the friendly name into a PowerShell EOL character
#Change mac text file to unix full#
# FullFilename : The full pathname of the file to be modified. # mac, unix or win : The file endings desired. set-eol.ps1 -lineEnding -file FullFilename # Change the line endings of a text file to: Windows (CR/LF), MacOS/Unix (LF) or Classic Mac (CR) This script will work even for a source file that contains a mixture of different file endings. How-to: Change the line endings of a text file Ī PowerShell script to change the line endings of a text file.
