SUSEUnbound
Would you like to react to this message? Create an account in a few clicks or log in to continue.


 
HomeHome  PortalPortal  Latest imagesLatest images  SearchSearch  RegisterRegister  Log in  
openFate
Here Documents Fatelogo_small openFATE - openSUSE feature tracking
Latest topics
» Difference between 42.2 and 42.1
Here Documents Emptyby findoctr Thu Dec 15, 2016 7:53 pm

» openSUSE Leap 42.1 ?
Here Documents Emptyby findoctr Fri Feb 05, 2016 8:09 pm

» Happy Turkey Day
Here Documents Emptyby findoctr Thu Nov 26, 2015 1:45 pm

» Happy 4th of July!
Here Documents Emptyby bozo Sat Jul 04, 2015 12:56 pm

» It's been a while ...
Here Documents Emptyby bozo Mon Feb 23, 2015 8:34 pm

» Mondo chillers
Here Documents Emptyby bozo Wed Feb 18, 2015 5:11 am

Navigation
 Portal
 Index
 Memberlist
 Profile
 FAQ
 Search
IRC Channel
You can also find us on IRC's freenode.net as #suseunbound.

 

 Here Documents

Go down 
AuthorMessage
welan
Admin
welan


Posts : 248
Join date : 2010-02-23
Age : 60
Location : snow drift in minnesota

Here Documents Empty
PostSubject: Here Documents   Here Documents EmptyMon Mar 15, 2010 5:55 pm

Sometimes you want to print a large section of text or feed a lot of text to another command. Rather than using several echo commands, you can employ the shell's here document feature.

The following is a script that shows how here documents work:

#!/bin/sh
DATE=`date`
cat <<EOF
Date: $DATE

The output above is from Unix date command.
It's not a very interesting command.
EOF

The items in bold control the here document. <<EOF tells the shell to redirect all lines that follow to the standard input of the command that precedes <<EOF, which in this case is cat. The redirection stops as soon as the EOF marker occurs on a line by itself. The marker that you use doesn't have to be EOF — use any string that you like, but remember that you must use the same marker at the beginning and end of the here document, and that convention dictates that the marker be in all uppercase letters.

Notice also that there is a shell variable in the here document. The shell expands shell variables inside here documents. This is especially useful when you're printing out some kind of report and have many variables to put into a larger form.

And thank you for flying Penguin Air.
Back to top Go down
 
Here Documents
Back to top 
Page 1 of 1

Permissions in this forum:You cannot reply to topics in this forum
SUSEUnbound :: Help Section :: Tips and Tweaks-
Jump to: