Let's write a script for using the sort command along with the here document:
- Write the script here_02.sh as follows:
#!/bin/bash sort << EOF cherry mango apple banana EOF
- Save the file, give the permission to execute, and run the script as follows:
$ chmod u+x here_02.sh $ ./here_02.sh
- The output is here:
apple banana cherry mango
In this script, the here document is enclosed between the EOF pattern. We have used the here document to supply text to the sort command.