Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

For example:

mycommand.py -a `cat myfile.json`

In this example, I need the contents of myfile.json to be passed as the value to the -a argument of mycommand.py. This almost works, but I need the file contents (which include double quotes and newlines) to be surrounded by quotes. This does not work:

mycommand.py -a '`cat myfile.json`'

The use of the single quotes prevents the backtick quotes from working.

share|improve this question
    
homework problem? – mdpc Jun 27 '13 at 1:21

Use double quotes.

mycommand.py -a "`cat myfile.json`"
share|improve this answer
3  
Dang! You type faster than I do! As long as I’ve got an extra 42 seconds, let me suggest changing that to mycommand.py -a "$(cat myfile.json)". – Scott Jun 27 '13 at 0:34
    
Thanks. This is so obvious I almost feel like I should delete the question... – Landon Kuhn Jun 27 '13 at 0:34
    
Oh, probably somebody will do a search and discover that an equivalent question has been asked and answered before, and then this one will be closed as a duplicate. – Scott Jun 27 '13 at 0:37
    
I looked around.. it's kind of a hard one to search for. – Landon Kuhn Jun 27 '13 at 3:25
    
It's hard to search for something when you don't know what it's called (command substitution for future reference). – Dean Jun 27 '13 at 3:31

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .