Three Ways to Feed File Contents into Command Line Arguments on Linux
To save you from (mis)typing it by hand…
Sometimes it is useful to read file contents into command line arguments on Linux. For example, you might have a long line containing a cryptic token string or JSON that would be tedious and error prone to type out.
There are few ways this can be achieved.
One way is to pass the contents of a file into a command line with:
./myapp $(<file.txt)
If your shell doesn’t support that, then this older method may work:
./myapp $(cat file.txt)
Another way to pass file contents on the command line, is to use the following:
./myapp `cat file.txt`
Conclusion
These are three ways that a file’s contents can be used on the command line. What other ways are there?