Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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
add comment

1 Answer 1

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... –  landon9720 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. –  landon9720 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
show 1 more comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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