Discuss What does EOF do? in the Other Programming Languages forum on Dev Shed. What does EOF do? A place for discussing programming languages not covered in specific forums such as Assembler, COBOL, etc. - you get the idea.
The ASP Free website provides in-depth information on the latest developer tools available from Microsoft. Our cadre of writers, highly experienced industry experts, reveals the best ways to use established technologies as well as new and emerging technologies. Our coverage of Microsoft's development and administration technologies is among the most respected in the IT industry today.
ASP Free and Iron Speed Designer are giving away $5,500+ in FREE licenses. Iron Speed's RAD CASE toolset can save up to 80% of your coding time. One free license per week, one perpetual license per month! Download and Activate to enter!
Intel® Graphics Performance Analyzers is a powerful tool suite for analyzing and optimizing your games, media, and graphics-intensive applications. Used by some of the best developers on the planet, Intel GPA lets you maximize your app’s performance.
Location: Woodland Hills, Los Angeles County, California, USA
Posts: 8,978
Time spent in forums: 1 Month 2 Weeks 6 Days 22 h 11 m 29 sec
Reputation Power: 3561
That is known as a "Here Tag". Basically it tells the shell that you are going to enter a multi-line string until "Here". You could call it anything you want, not just EOF or STOP.
Code:
[mb@ironmaiden mb]$ cat > test <<HERE
> Hello
> world
> HERE
The <<HERE part tells the shell that you're going to enter multi-lines until the HERE tag. Thus the shell waits until it sees HERE to consider the rest of the stuff above it as input for cat.
Some rules about the Here tags:
1. The tag can be any string, uppercase or lowercase, though most people use uppercase by convention.
2. The tag will not be considered as a Here tag if there are other words in that line. In this case, it will merely be considered part of the string. The tag should be by itself on a separate line, to be considered a tag.
3. The tag should have no leading or trailing spaces in that line to be considered a tag. Otherwise it will be considered as part of the string.
Here's another chunk to consider:
Code:
[mb@ironmaiden mb]$ cat >> test <<HERE
> Hello world HERE <--- Not the end of string
> This is a test
> HERE <-- Leading space, so not end of string
> and a new line
> HERE <-- Now we have the end of the string
Note that in the above, we have the word HERE showing up 3 times. The first two times, it occurs with other words or leading spaces and hence it is considered as part of the string.
Many scripting languages (perl, PHP, awk, ruby etc.) support the concept of the "Here tag", so it isn't unique to bash alone.
__________________ Up the Irons
What Would Jimi Do? Smash amps. Burn guitar. Take the groupies home. "Death Before Dishonour, my Friends!!" - Bruce D ickinson, Iron Maiden Aug 20, 2005 @ OzzFest
Down with Sharon Osbourne Diary of a first time dog owner <-- my cousin's blog
Location: Woodland Hills, Los Angeles County, California, USA
Posts: 8,978
Time spent in forums: 1 Month 2 Weeks 6 Days 22 h 11 m 29 sec
Reputation Power: 3561
That's because when you enter the command, bash parses the first line and sees that it needs to run cat and redirect the output to a file called filename. It also sees that the input is going to come from STDIN (i.e. the terminal) and that it should read input until it sees your "here" tag. The bash parser can accept input/output redirection operators in any order really.