What is the line feed code for this string? I am sometimes taken care of.
\ r
Means return. It was used as a line feed code in older Mac OS (up to version 9).
\ 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.
$ echo -e "AAA\r\nBBB" | hexdump -c
0000000 A A A \r \n B B B \n
$ 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
$ var=$(echo -e "AAA\r\nBBB")
$ printf '%q' "$var"
$'AAA\r\nBBB'
Recommended Posts