eof
EOF
EOF is an acronym that stands for “End of file”
Shell
In shell, EOF is commonly used as a terminator in what is called a heredoc (“here document”).
It's when you want to supply a multiline text to a command to its standard output, using <<.
$ cat > hello.txt << EOF Here, you can write anything you like. It's not over until you actually type E-O-F. You can cancel with Ctrl + C. EOF
But this is just a convention. You can use any string you like in heredocs.
$ cat > hello.txt << whatever Now you can type EOF EOF EOF as much as you want until you type it whatever
C
In C programming language, EOF is a constant defined -1 which indicates an end of file.
// Compile: gcc main.c -o program // Run: echo 'Hello world' | ./program // Output: HELLO WORLD #include <stdio.h> #include <ctype.h> int main() { int ch; while ((ch = fgetc(stdin)) != EOF) { putchar(toupper(ch)); } return 0; }
Links
eof.txt · Last modified: (external edit)
