Skip to content

Latest commit

 

History

History
62 lines (46 loc) · 1.81 KB

carriage-return.md

File metadata and controls

62 lines (46 loc) · 1.81 KB
title date description noindex featured pinned series categories tags images authors lastmod status
What Is Carriage Return?
2024-04-04
A note about carriage return and how to remove it.
false
false
false
Bash
Powershell
Linux
Windows
strings
linux
shell
general
windows
Alimektor
2024-04-27
final

carriage-return

What Are Carriage Return, Linefeed, and Form Feed?

Carriage return means to return to the beginning of the current line without advancing downward. The name comes from a printer's carriage, as monitors were rare when the name was coined. This is commonly escaped as \r, abbreviated CR, and has ASCII value 13 or 0xD.

Linefeed means to advance downward to the next line; however, it has been repurposed and renamed. Used as "newline", it terminates lines (commonly confused with separating lines). This is commonly escaped as \n, abbreviated LF or NL, and has ASCII value 10 or 0xA. CRLF (but not CRNL) is used for the pair \r\n.

Form feed means advance downward to the next "page". It was commonly used as page separators, but now is also used as section separators. Text editors can use this character when you "insert a page break". This is commonly escaped as \f, abbreviated FF, and has ASCII value 12 or 0xC.

Script to Delete Carriage Return

{{< bs/toggle carriageReturnRemove >}}

{{% bs/toggle-item Bash %}}

sed -i 's/\r//g' "<filename>"

{{% /bs/toggle-item %}}

{{% bs/toggle-item Powershell %}}

$path = "<filename>"
(Get-Content $path -Raw).Replace("`r`n","`n") | Set-Content $path -Force

{{% /bs/toggle-item %}}

{{< /bs/toggle >}}

Links