In some heredocs, you see the keyword bash before the opener (<<), the name, and the File descriptor. For example:bash /dev/fd/10 10<<'SES'Why is the Bash there? I mean, we already work in Bash, and it's not like cat used to display the text and then redirect it to another file as in cat << EOT >> /file.txt hence I ask as a freshman, why we need the keyword bash there.
Why is there a bash keyword before some heredocs?
here document
bash there isn't a keyword, it's a command being executed. It's being passed the argument /dev/fd/10. The shell running the script (which may or may not be bash) is setting up a heredoc to be read from file descriptor 10.So, bash is being invoked to run the heredoc as a shell script. It's similar to if the line read bash /path/to/script.sh  in this case, the script is just coming from a heredoc instead.Why someone did that (instead of just using ( commands ) is impossible to answer without the context (and possibly the history as well). One guess (as DopeGhoti suggests) is that the script may be running under a different shell, and that bit requires bash. Another possibility is that the script's author just didn't know the alternate methods.As to why FD 10 is used instead of stdin, it could be because the script block needs to read from stdin as well.