There is a comment in the POSIX Standard's rationale for the simple commands section of the shell command language description that says:
Quote:
An example of redirections without a command name being performed in a subshell shows that
the here-document does not disrupt the standard input of the while loop:
But, I don't see anything in the standard that clearly specifies for what a here-document without a command is providing input. With the command exec a here-document does replace standard input for the current shell execution environment.
Playing around a little bit with the above example code in the POSIX rationale and the code supplied in post #1 in this thread, it appears to me that the here-document:
is a shell language comment similar to the C language comment:
except that any expansions occurring in that here-document may have side effects. For example:
might produce abbreviated output similar to:
If you wanted a multi-line shell comment without side effects (like the C example I showed earlier) you could quote one or more characters in the EOF string of the here-document:
which would then produce abbreviated output similar to the following (with the last line being exactly like that shown below):
Are we having fun yet?
These 3 Users Gave Thanks to Don Cragun For This Post:
I appreciate the fact that rules are for everyone and I screwed up by not putting a screen printout in code brackets...
However, I was a bit dismayed when I received the following and tried to reply to say "Thank you" for sending me the reminder. I could not reply and had no idea what the... (4 Replies)
Hello,
I am trying to place two commands in heredoc
below is the snippet
if ;then
actionOnTux="$actVerb"
else
actionOnTux="$actVerb"
fi
echo "Performing ACTION: $action on $tux@$srv .....\n"
if ; then
... (5 Replies)
$ cat bashtest
#!/usr/local/bin/bash
echo <<<"EOF"
line1
line2
line3
EOF
$ ./bashtest
./bashtest: line 3: line1: command not found
./bashtest: line 4: line2: command not found
./bashtest: line 5: line3: command not found
./bashtest: line 6: EOF: command not found
What am i doing... (4 Replies)
Hi,
I am facing an issue wherein some temporary files (here docs) are getting created in /tmp and are not getting deleted automatically.
When i check the list of open files with below command i can see one file is getting appended continuously.(In this case /tmp/sfe7h.34p)
The output is... (4 Replies)
I currently use this message to send e-mails in a script but I would also like to save the output of this code to a file as well while preserving the variables. What's the easiest way to accomplish this?
#Sending mail notification
when=`/bin/date`
/usr/sbin/sendmail -t >2 <<-EOM... (2 Replies)
Hi,
Is there any way to check the error in heredoc?
Code:
/export/opt/SCssh/3.7.1_C0/bin/sftp -B - csi@192.168.1.100 <<FTP
lcd /WEBSERVER_LINK/data_logs/
ls pub/csidata/GeneralAppFields_8_1_Feed.out
get pub/csidata/GeneralAppFields_8_1_Feed.out
quit
FTP
Now I want to check... (1 Reply)
Hi,
I'm having heredoc to get files from ftp server.
#!/bin/bash
/export/opt/SCssh/3.7.1_C0/bin/sftp csi@192.168.1.100 <<GET_FILES
lcd /WEBSERVER_LINK/data_logs/
ls -l pub/csidata/GeneralAppFields_8_1_Feed.out pub/csidata/CtcCatalog_7_3_3_Feed.out
get... (13 Replies)
Hi folks
What I'm trying is to build a partitioning script.
I can pass a HEREDOC to fdisk just fine. Like this:
fdisk /dev/sda << EOF
p
q
EOF
but I don't know how to put that HEREDOC into a varible to pass it to fdisk.
This is what I have tried so far (no luck)
#!/bin/bash
... (3 Replies)
I'm new to unix and wanted to know if there are UNIX tools/programs on the market that can be loaded onto my laptop or external hard drive that I can use to practice and test what I'm learning. :) (2 Replies)