Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

what's this bash redirection operator? "<<!"

Tags:

bash

I saw the following bash code:at 19:00 <<! echo "job 1". I have two problems:

  1. What's this redirection operator: <<!?
  2. 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?

like image 990
象嘉道 Avatar asked Dec 21 '22 17:12

象嘉道


1 Answers

From bash reference manual

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

  1. You shouldn't need to specify anything after word(in your case !)
  2. Then you should specify at job on one or more lines
  3. Finally, add a line containing word(again, in your case !)
like image 139
Alexander Putilin Avatar answered Jan 09 '23 13:01

Alexander Putilin