0

So I'm trying to write this script where it will echo out a name of a command, but I don't want it to actually run that command that it's echoing out, in this example I'm using screen

printf "You run this command with screen to run in a background."

but what I find to be having issue with this is that it's running screen command in that printed output, and it shows an error as a result. Is there some escape character I need to enter to prevent this from happening, so that the rest of the script can run properly?

  • 3
    Are you sure you're running what you say you're running? There's no way the above will execute the screen command. – Wodin May 01 '17 at 05:54
  • I am sure, I just said so before that it outputs an error when I try to run it in my own script. –  May 01 '17 at 05:57

1 Answers1

-3

When you write an expression within double quotes in bash it will execute the commands within it. If you don't want it to execute the command enclose your statement within single quotes

 'You run this command with screen to run in a background.'
Shubham Khatri
  • 270,417
  • 55
  • 406
  • 400
  • so there's actual differences between Double and Single quotes huh? –  May 01 '17 at 05:56
  • Yes, anything within single quotes won't be recognized as a command – Shubham Khatri May 01 '17 at 05:58
  • 3
    Just enclosing an expression in double quotes won't result in it getting executed! Take a look at this post: http://stackoverflow.com/questions/6697753/difference-between-single-and-double-quotes-in-bash – codeforester May 01 '17 at 06:11
  • 4
    This is **wrong answer**. No command is executed within double quotes, unless you explicitly don't ask for it. Try: `echo "date"` or `printf "date"` will output the string `date` and not the current date. Even without the quotes, e.g. `printf date` will not execute the command. You must use `echo "$(date)"` for executing. How this could get accepted?! – clt60 May 01 '17 at 07:56