Reputation: 3885
I saw the following bash code:at 19:00 <<! echo "job 1"
. I have two problems:
<<!
?I wrote the following script code:
at 19:00 <<!
echo "job 1"
at 20:00 <<!
echo "job 2"
When I executed this script, atq
command only showed one job, the first one. What's the matter? And how should I submit the two jobs via this script correctly?
Upvotes: 4
Views: 4263
Reputation: 2342
3.6.6 Here Documents
This type of redirection instructs the shell to read input from the current source until a line containing only word (with no trailing blanks) is seen. All of the lines read up to that point are then used as the standard input for a command.
The format of here-documents is:
<<[−]word
here-document
delimiter
So
word
(in your case !
)at
job on one or more linesword
(again, in your case !
)Upvotes: 6
Reputation: 753695
The <<!
is a here document, as Nya explained.
You should write:
at 19:00 <<!
echo "job 1"
!
at 20:00 <<!
echo "job 2"
!
Without the lines starting !
, your here document was the rest of the shell script, which is why there was only one command in the atq
. (But, the command would have scheduled the second job when it ran!)
Upvotes: 5