Traditionally, in some contexts there is a End-of-file 'character'
- MS-DOS / CMD.EXE uses CTRL+Z
- Linux uses CTRL+D
CTRL-Z is code 26, CTRL-D is code 4 in the ASCII table.
These are still in use in situations when you use stdin
(in the meaning as applied in "C" programming and general console/tty IO).
e.g.
C:\> copy con myFile.txt
This is text to go into the file.Enter
CTRL+Z
C:\> type myFile.txt
This is text to go into the file.
C:\>
The very same sequence works in Linux'en with the difference that you start with
$ cat >myFile
and end with CTRL+D, then cat myFile.txt
instead of type
.
...
If you're programming though, you will hardly see any effects of these characters.
I am at this writing not aware of any function call that would stop at these characters.
Read the documentation for your software / library - if there is no statement about the effect of these, then you're not likely to see anything strange happen.
Line endings - CR and LF combinations, code 13 and 10 - is a bit different though, it can get quite messy if you transfer TEXT files from one system to another.
unix2dos
and dos2unix
are shell commands available on Linux'en - for this purpose.
Sample bash session:
$ echo -e "First line\n\x04Second line."
First line
Second line.
$ echo -e "First line\n\x04Second line." | od -t x1z
0000000 46 69 72 73 74 20 6c 69 6e 65 0a 04 53 65 63 6f >First line..Seco<
0000020 6e 64 20 6c 69 6e 65 2e 0a >nd line..<
0000031
$ echo -e "First line\n\x04Second line." | grep line
First line
Second line.
$ cat >myFile.txt
Check this out
$ cat myFile.txt
Check this out
$