How can I have some of the options to a unix command come from a file? That is the file does not contain all the options -- other options are specified elsewhere.

For example I have the filelsoptions.txt with the following content:

-F -G

Now I would like to execute

ls -a <and all options specified in the file lsoptons.txt>

ie, I want to execute ls -a -F -G.

That is, specify some of the options, but other options are read from a file.


  • This is obviously a cooked up example. My real use case is that my shell script needs some parameters that were provided in a TeX file. So, instead of having the user duplicate the information in multiple places, I will have the TeX write the desired options into a file so that the shell script can also have access to them. One option would be to have the TeX generate the entire script, but would much easier if I could just read the options from a file.

1 Answer 1


For the trivial example listed above,

ls -a $(cat lsoptions.txt)
  • Am glad that that was easy. Will try that out. Oct 7, 2014 at 5:24
  • With bash, you can use the builtin $(< lsoptions.txt) Oct 7, 2014 at 10:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.