Interview Prep/Shell Scripting/Variables, quoting and expansions

What is the difference between `$( < file )` and `$(cat file)`?

BeginnerConceptVariables, quoting and expansions
Answer

Both read the whole file into a string with trailing newlines stripped. $(&lt; file) is a Bash shortcut that reads the file without forking cat, so it is faster in loops. If the file is missing, both print an error; $(&lt; file) fails with bash: file: No such file or directory.

token=$(&lt; /run/secrets/api_token)
All Shell Scripting questions Roadmap: Shell scripting (Bash)

More on Variables, quoting and expansions