[LINUX] Shell command to visualize line feed code

What is the line feed code for this string? I am sometimes taken care of.

First, review the types of line feed codes

CR (Carriage Return)

\ r Means return. It was used as a line feed code in older Mac OS (up to version 9).

LF (Line Feed)

\ n Means a line break. It is used as a line feed code in Linux and macOS.

CRLF

\ r \ n The above two are consecutive. It is used as a line feed code in Windows.

Commands to visualize

When using the hexdump command (pipeline)

$ echo -e "AAA\r\nBBB" | hexdump -c
0000000   A   A   A  \r  \n   B   B   B  \n

When using the od command (pipeline)

$ echo -e "AAA\r\nBBB" | od -c
0000000   A   A   A  \r  \n   B   B   B  \n

To visualize the character code of the file:

$ cat tmp.txt | od -c
0000000   A   A   A  \r  \n   B   B   B  \n

When using the printf command (variable)

$ var=$(echo -e "AAA\r\nBBB")
$ printf '%q' "$var"
$'AAA\r\nBBB'

Recommended Posts

Shell command to visualize line feed code
Command to generate QR code
[Python] How to test command line parser click
How to receive command line arguments in Python
Quickly display the QR code on the command line
Linux [shell command]
Easy conversion without worrying about line feed code conversion
[Introduction to Udemy Python3 + Application] 67. Command line arguments
Convert XLSX to CSV on the command line
How to create an article from the command line
python2 series / 3 series, character code and print statement / command line
(Remember quickly) How to use the LINUX command line
Command line introductory notes
Rewrite Python2 code to Python3 (2to3)
Shell script command replacement
Linux command line shortcut
Command line tool to put .gitkeep in an empty directory
Code block when writing console (shell) command execution in Qiita
How to specify command line arguments when debugging in PyCharm
curl command show http status code in response (#Linux #Shell)
Procedure memo to put AWS command line interface in CentOS6